Reputation: 2245
I'am building a chat application in node.js. Now I'am receiving new messages with ajax. I am sending request every 3 seconds. I noticed that stackoverflow doesn't send any requests to fetch new data. SO opens one stream ws://sockets.ny.stackexchange.com/ (status 101) and in this way retrieves new content (like reputation, new comments, new posts). How to do this ?
Upvotes: 1
Views: 254
Reputation: 5806
The ws://
protocol stands for websockets. You can read more about it in this Wikipedia article. You can find in this question some pointers on how to get started with websocket, while this question lists all the browsers that support them.
Finally, the following question is a community wiki of all available libraries for nodejs: Which websocket library to use with Node.js?
As Dandavis (brilliantly) pointed out, socket.io is quite a popular library, though I haven't personally tried it. It does however have much wider support (as shown by the large number of questions on this site)
Upvotes: 2