Tim,
Take a look at this:
https://github.com/sockjs/sockjs-protocol
and especially:
http://sockjs.github.com/sockjs-protocol/sockjs-protocol-0.1.html
This subproject tries to define the spec, but peeking at `sockjs-node`
code may still be necessary.
Cheers,
Marek
Thanks!
On Dec 3, 10:56 pm, Marek Majkowski <maje...@gmail.com> wrote:
Understandable. Let me give you a brief guide on the coffescript
implementation.
There are kind of three parts.
First, there is an entry point:
https://github.com/sockjs/sockjs-node/blob/master/src/sockjs.coffee
It's mainly a glue between a simplistic web framework:
https://github.com/sockjs/sockjs-node/blob/master/src/webjs.coffee
(which in principle is really simple, few regular expressions,
few lists of 'filters'), and various transport/protocol handlers.
Second, there are many http protocol handlers, although there
is quite a lot of things happening, the underlying logic is quite
simple. All the transport are doing basically the same, just decorating
the responses differently, according to a particular transport:
https://github.com/sockjs/sockjs-node/blob/master/src/trans-eventsource.coffee
https://github.com/sockjs/sockjs-node/blob/master/src/trans-htmlfile.coffee
https://github.com/sockjs/sockjs-node/blob/master/src/trans-xhr.coffee
https://github.com/sockjs/sockjs-node/blob/master/src/trans-jsonp.coffee
This, kindof dumb, transport are have shared logic that deals
with timeouts and stuff. This is actually the interesting (and hard) part:
https://github.com/sockjs/sockjs-node/blob/master/src/transport.coffee
And finally, there is an implementation of websocket protocol:
https://github.com/sockjs/sockjs-node/blob/master/src/trans-websocket.coffee
https://github.com/sockjs/sockjs-node/blob/master/src/trans-websocket-hixie76.coffee
https://github.com/sockjs/sockjs-node/blob/master/src/trans-websocket-hybi10.coffee
This is a surprisingly large chunk of code.
Cheers,
Marek