Rohini Kumar
Rohini Kumar

Reputation: 249

how the update messages in stack overflow site are being shown

i would like to know how the update messages in this stack overflow site have been implemented.

To be more precise, for example while i am trying to reply for question and i am in the middle of typing my response, i will see a message on top of the page saying a new answer has been added. How is this feature has been implemented.

AFAIK, the possible way can be HTML5 websocket or serversocket technology. is there any other way to achieve this kind of push notification system especially using java, spring and jquery environment?

Not sure how to tag this question. correct the tags if i am wrong.

Upvotes: 4

Views: 218

Answers (3)

kosa
kosa

Reputation: 66657

SO uses reverse ajax/comet technology to show those messages. I remember reading some discussion on meta about this feature, couldn't exactly find out the link for it at this moment. Will update as soon as I find.

Based on programming language framework name may change (websockets (or) socket.io etc.,), but at the end they all are from comet framework.

Update:

Here is SO meta discussion on this topic.

Upvotes: 6

mkhelif
mkhelif

Reputation: 1559

There are several ways to achieve that:

  • Polling: using JQuery you issue a request regularly (every 5sec for examples) which retrieves the updates from the server.
  • Streaming: you issue a request, the server does not set a Content-Length to the response and "never" close the socket. This way you can send data from server to client whenever you want. But it means that for every client a connection is hold by your server.
  • Long polling: mix between the two previous ways. The connection is hold by the server but with a timeout. If no new data is available, the server closes the connection and the client reopen a new one after a moment.

Thoses are Push technologies: http://en.wikipedia.org/wiki/Push_technology

Of course there are over ways to achieve that.

Upvotes: 2

I have used the Direct Web Remoting framework with success. (DWR).

Upvotes: 2

Related Questions