I have a server and many clients (around 50 clients) who connect to that server based on a web application, which is of course based on HTTP protocol, which in turn uses TCP/IP (correct me if I'm wrong, cause I'm not really good at networking).

The problem is that, I should develop an alert mechanism, in which, when somebody submits a form with dangerous values, the manager (who is also connected via the same web application) should receive an alert pop-up on his screen, almost real-time (instantly).

However, since the HTTP protocol is stateless, I' a little puzzled here. I don't know how I can implement this.

One of the solutions could be to use JavaScript alongside setInterval() function to pull data each second from server. But this seems a little dirty to me and unprofessional.

2 Answers
2

You should use some kind of ajax push (see Comet) to notify the clients. It can eliminate the need for polling, you basically keep an established connection open which can be used to notify the browser of ocurring events. However, this does not work with all browsers. You fall back to "long polling" in such cases.

I think this is the kind of reason WenbSockets were created for. If you don't need compatibility with older browsers you might want to use this instead of polling. You should probably use polling as a fallback anyway.