Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

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.

Do you guys have any idea of implementing another solution?

share|improve this question
    
This post may help stackoverflow.com/questions/640488/… –  Emmad Kareem Sep 12 '11 at 10:49
    
What kind of clients? Thin (browser based) clients or heavy clients? –  ysdx Sep 16 '11 at 11:24
    
@ysdx, think clients. Clients with browser support only. –  Saeed Neamati Sep 17 '11 at 10:06

2 Answers 2

up vote 3 down vote accepted

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.

share|improve this answer

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.

http://www.w3.org/TR/websockets/

I'm not sure how stable the spec/implementations are these days (it was not very stable not so long ago). It seems the latest spec is implemented in Firefox 6 and Chromium 14.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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