3 ms·
First, you seem to be confusing WebSockets, which is a protocol and low-level DOM interface for dealing with that protocol with Socket.io, which is a software f
by LeafStorm 15y ago
First, you seem to be confusing WebSockets, which is a protocol and low-level DOM interface for dealing with that protocol with Socket.io, which is a software framework for client-to-server messaging that uses WebSockets as one possible transport. (And pretty much has to take over your server entirely in order to work.) It's like reading an article about Rack and saying, "I don't see how this is any better than Ruby on Rails."
Now that that's out of the way: Strictly speaking, WebSockets are "better" than SSE in that you can do everything you can do with SSE using WebSockets. However, the SSE protocol:
* Is plain HTTP, instead of adding on a separate protocol,
* Has an easy-to-generate text-based format,
* Does not require major upgrades to your server, and
* Can be emulated on non-conforming browsers using standard XHR's.
So when all you need to do in realtime is send data from the server to the client (remember, you can still use XHR's to call back to your server), SSE is far easier to implement both on the client and on the server.