list
list copied to clipboard
Workshopper for web-sockets (with socket.io?)
I have been asked at the NodeSchool Osaka tonight about a workshop specifically for socket.io. I was shocked to find that it doesn't exist. Probably there should be one at least on that topic. Isn't this one of the most-common uses of Node.JS?
@martinheidegger We were shocked as well, the same question appeared at NodeSchool Silesia meeting. We're trying to develop something here: https://github.com/rspective/websockito (we've used recently released how-to-npm
as a starting point).
At the beginning we would like to focus on two modules - ws
and socket.io
used only on the server side, at least for now. Feedback and help is welcome!
Do you have any idea (or even better - feedback from community) what topic should be covered in such workshop?
@timoxley and me just talked on gitter about a content for a socket.io workshopper and we came up with two different approaches to it that could build on each other.
Approach 1: Form -> Socket
A form submission workshop that incrementally works up to websockets:
- Submit with HTTP Post. Reload data as natural page refresh on POST.
- HTTP Post over XHR. Reload data by auto refreshing page.
- Manually update results with HTTP GET with XHR.
- Switch from manual update to polling.
- Switch from polling to long-polling.
- Switch from long-polling to raw SSE
- Switch from raw SSE to raw WebSockets
- Switch from raw WebSockets to socket.io
Approach 2: (Integrated) Socket -> Hardcore Socket
Build against a decentralised (optionally online) Server system that starts with the basics of sockets but soon becomes a lot more complex.
- Use sockets to send a message to a central server. (hosted on heroku/modulus/gcp/aws/.. <- sponsor?)
- Receive a message from the server
- Automatically try to reconnect to the server
- Change the socket system to use an automated endpoint lookup (keyword: bittorrent)
- Create a socket server and relay a message from a (given) client to the central server.
- Use data from the central server to store a shared state.
- Connect an express/hapi/koa session to a socket.io session and send it to the central server.
- Deny access to a certain client based on session and write log to central server.
- Cleanly shutdown the server with a notification towards the central server and clients.
- Send A/V content over socket
- Secure the socket connection
The flow I described is designed to ensure people understand the lesser-known alternatives like long-polling and SSE as well as giving people a taste of how to use websockets.
Underlying motivation is to curb the "websockets for everything" trend that's been going on for a few years now while alternatives are more widely supported, accessible and often more suited to the task at hand. Particularly, I'd like to raise awareness of SSE, which can replace a large number of places where websockets are currently used, without the proxying/intermediaries hassles of websockets (though this is getting better).