Basically, I have a remote hosted server somewhere https://nnn.com

And then I have the NNN Desktop Client.

The Desktop Client shows information X.

I change information X from the remote hosted server.

How can I make it so that the displayed information X in Desktop Client is automatically updated?

At first I thought that the solution was web-hooks, but from what I understand, the Desktop Client would then need a url.

And then I thought of the Desktop client calling an endpoint from the remote hosted server, checking if there are any updates. Polling, basically. But I don't know if that's the right way. And if it is, do I check every 5 seconds? 1 minute? That I do not know.

Any help or guidance is appreciated.

You want to keep a persistent socket connection open so that the desktop client can subscribe to a channel of messages the server publishes. Roughly the model is to connect to your server (whether through a load balancer, a cloud provider, whatever) and keep that connection alive as long as the client is interested in receiving updates. The client has to periodically check to see if it has recieved any data (though some libraries like Boost's Asio make use of OS-level features to make this asynchronous, too) and then act on it.

For example, in the web world, it is easy to do this with WebSockets, which also have good client libraries available for every major language.

It would also be advantageous to avoid polling on the server side. For instance, Postgres has asynchronous notification built into it. What you do, exactly, will depend on the particulars of your data management solution.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.