how to connect a desktop application with a webpage?
I am using VS2010 - C# - WPF I have a desktop application that I built, and this application shows some values. these values are brought from a web page that I made too.
Now everytime I change the values on the webpage the values mu开发者_运维百科st be changed on the applications.
But I don't want the applications to keep refreshing because the refresh rate is low, so I want the webpage to notigy all apps. on a button click from the website.
is such thing possible ? knowing that anyone can download the application but no one can access the website but me ?
I will consider your problem as an academical one of "How to get the server to push notification to the client" and answer, but I think the better, and more common solution is for the client application to do polling on a server endpoint, and update itself, as Tejs says.
As for the question, You have to
- Make your application listen to HTTP connections on a free port.
- Send a message to the server that you are listening on Port X for http connections. This is like a registration, that registers your client to the server.
- On the server side build an endpoint where clients can register, and maintain a list of registered clients to be notified.
- When notification needs to happen, use the list to connect to and push notification to the clients.
Top issues you will face are, problems like what to do if client does not respond, how to maintain the list - in-memory or in-DB and so on.
There's not going to be any kind of magic here; it depends on your update interval. If you want them to just get the freshest value on the applications first start, then you can simply make the web request in the application load method. Otherwise, you will need to implement some kind of polling for updates in your application, just on a long interval (say 2 hours between each request, etc).
精彩评论