I have been given a task to design an ASP.net web application that does the following:
(1) A related mobile application will be used by associates around the city. As they use the mobile application, their GPS locations are sent to a server.
(2) The web app must use Google Maps to draw a map of the city and display markers showing the location of each associate.
It was suggested to me that the web application should automatically refresh the data every three minutes.
However, I can't stop wondering why I'm stuck with a polling solution; this seems obsolete in the 21st century.
As far as the communication between the browser and the web server, I know of two solutions.
One is a long-running HTTP request kept open for the duration of the user's visit to the app. (Demo here: http://danielsadventure.info/webconsoledemo)
The other is HTML5 Web Sockets.
I think that either of the above solutions should be sufficient for streaming data from the server to the browser in near real-time.
That being said, the data model of the web application is in MS SQL. I know of no way to make it so that the web server knows when the data model is updated without making the web server poll the SQL server.
I suppose that one possible solution might be to get the associate locations from SQL when the web app loads and then when updates from associates come it, send them down to all connected web browsers at the same time that they are updated in SQL. That would entail having the thread that processing the incoming data from the associate automatically communicate with other threads that were sending location data to a browser and I don't know how to do that. Even then, I see myself having to poll one thread from another.
What is a good way of accomplishing my client's request without having to resort to a polling solution? If a polling solution is necessary, how can I minimize the drawbacks to it?
I know that there are solutions out there. Otherwise, how would GMail be able to tell you when a new message arrives?
Edit: A specific situation: Suppose that Adam is an associate in the field and Omar is an operator watching Adam's whereabouts using this application.
Omar logs in; his browser sends a request to the server, which sends back a response telling where Adam is located. Omar's browser then starts a long-running HTTP request to receive updates about where Adam goes.
A few minutes later, Adam hops into a company truck and drives down the road. As the truck begins to move, Adam's mobile application sends an update to the web server indicating that he has moved.
Given the above scenario, how can the web server communicate to Omar's web browser that Adam has moved (without Omar's browser or the web server engaging in any sort of polling)?