Wikipedia:Reference desk/Archives/Computing/2020 September 12

= September 12 =

WebSocket question
At work I'm working on a system consisting of a web application and an independent desktop application. Both run on Windows 10, and the desktop application is written in .NET Framework C# while the web application runs .NET Framework C# on the back end and HTML and JavaScript on the front end.

The two applications in the system communicate via WebSockets. I've managed to have the web application open a WebSocket to the desktop application via JavaScript, and the desktop application then receives a message and acts on it.

But how can I do it the other way? I also need the desktop application to be the one to initiate the message passing and the JavaScript on the web application then receives the message. How can this be done? J I P &#124; Talk 13:28, 12 September 2020 (UTC)


 * @JIP, WebSockets are bi-directional, so you can just get the server (in this case the desktop) to send a message and handle this in the webapp via the .onmessage event (i.e. ). This all varies on whatever socket server library you're using in .NET, but they all should include a send function. You may find https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API useful. Hope this helps :) Ed   talk!  18:22, 12 September 2020 (UTC)