I am working on a project in which we have a desktop application that should be able to receive commands from a web application. To solve this issue, using sockets seems like a good approach (instead of long polling and various other techniques).
The desktop application also uses a web API, and this is secured with mutual authentication in SSL. The sockets should also be secured with SSL.
The question is: what is the best way to handle large amounts of sockets?
I have thought of a solution which involves using a "relay socket". Basically the desktop application creates a socket to [The Relay Station]. Whenever an action should be sent from the web application, the web app also creates a socket to the relay station.
The web app sends a command saying "relay [this] to [socket]".
This approach requires that:
- All the desktop-to-relay sockets must be persistent
- The desktop application must identify himself, so that the webapp can reference him in his commands
- The relay station needs to keep track of all the desktop application sockets, and map those to a unique identifier.
This gives me a good structure, but it also arises some questions:
- What should the identifier be?
- Is there a better way of sending commands from [WebApp] to the correct desktop application, without using such approach?