A WebSocket Primer
caitiem.com
caitiem.com
http://www.html5rocks.com/en/tutorials/eventsource/basics/
SSE is realtime server->client protocol that's fully compatible with HTTP and has lower handshake overhead (no Upgrade roundtrip, doesn't require HTTPS to go through proxies).
It's also not supported by IE yet: http://caniuse.com/eventsource
Compare with http://caniuse.com/websockets
Looks like Chrome and Firefox have had support for quite some time. I'm alright with that.
Probably long-poll, a single connection from client to server kept alive with the occasional byte sent one way which sends the message and disconnects when there is something to send (the disconnect, requiring a new request from the client is because some clients won't process what has been sent immediately unless the connection is closed).
I once wrote a messaging client that operated this way. It is efficient in terms of bandwidth use and client footprint, though if you are using a process based we server it can be quite inefficient there (an event driven service on few processes/threads is far more efficient for handling many long-lived low-activity connections).
The idea of being able to insulate the rest of the code from the specifics of which lower-level library I'm using is very attractive. On the other hand, any abstraction layer can introduce bugs in its own right. Thoughts about the tradeoff?
Arnout Kazemier (the lead dev) is a really nice guy and when I pinged him about the egine.io bug, he pushed out a change to Primus 24 hours later that worked around the bug and let me continue to use engine.io as the transformer.
YMMV but so far I've no regrets using it.
What is really interesting is just how easy it is to use WebSockets with the latest libraries. I've got a project in .NET that relies on a lot of Microsoft-specific libraries right now. But with the ease of WebSockets, I can rewrite the UI in HTML5 like we always wanted and get around to rewriting the MS-specific stuff in Java or Python more likely whenever I feel like it.
It's like completely platform agnostic pipes, in a way that TCP/IP sockets never seemed to quite do.
EDIT: I think it's just that I don't have to listen for new connections and figure out how to bind them in a loop that I keep alive myself. I get an event when users connect.
Need to clean up a few things, but it was a neat 45 minutes.
Suggest the title be changed to:
A WebSocket Primer for .Net 4.5
The rest of it is a cool read, though. Thanks for submitting.