Playing with Web Sockets

Been playing around a bit with web-sockets under Twisted. This time I didn't go with autobahn, as the last time I played with it I just wound up stuck on lots of stuff I didn't need. What I decided to play with is a Web Socket based server-controlled messaging daemon. It's *not* going to run your bit enterprise, it's just me playing around.

The idea:

* you have a django web site
* you want to have any process on the server be able to send messages to connected sessions on any number of channels
* you want the server-side api to be dirt-simple-dumb (as in, you could include it in a bash script)
* you may want to allow a remote client to send messages to a channel as well
* there is no configuration happening on-the-wire, all control is handled by the server
* the server controls which sessions can read/write to each channel
* the server also controls which sessions can be connected

I went with txWS as the web socket implementation, mostly because it was simple to comprehend the source code. The use of the web socket isn't really all that relevant to the application, it's just how messages get to/from it. The low-level server-side sending is done with inotify watches on a directory structure (stored in a RAM disk). Server processes can write files directly or use a command-line to send them.

I'd say the code is now at "sketch" level. You can start up an ssws-server, run ssws-session --readable mychannel my-session-key to enable connection/reading on a channel, and then connect your web-browser to the ssws-server via the included JQuery-based Javascript object. Lots of critical bits are missing, and I still haven't tried it behind an nginx 1.6 proxy setup for wss support.

Anyway, the sketch is up on github https://github.com/mcfletch/ssws

Comments

Comments are closed.

Pingbacks

Pingbacks are closed.