Streaming sockjs for node and the browser.
'log'event instead of spamming stdout (silence)
Browser code that takes in a stream of 0s and 1s from the server and inverts them:
var shoe = ;var through = ;var result = document;var stream = ;stream;
Server code that hosts some static files and emits 0s and 1s:
var shoe = ;var http = ;var ecstatic = __dirname + '/static';var server = http;server;var sock =;sock;
The server emits 0s and 1s to the browser, the browser inverts them and sends them back, and the server dumps the binary digits to stdout.
By default, there's no logspam on stdout to clutter the output, which is a frustrating trend in realtimey websocket libraries that violates the rule of silence.
Just wait for a client to connect and you'll see:
$ node server.js001011010101101000101110010000100
Since dnode has a simple streaming api it's very simple to plug into shoe.
Just hack up some browser code:
var shoe = ;var dnode = ;var result = document;var stream = ;var d = ;d;d;
and hack up a server piping shoe streams into dnode:
var shoe = ;var dnode = ;var http = ;var ecstatic = __dirname + '/static';var server = http;server;var sock =;sock;
Then open up
localhost:9999 in your browser and you should see:
beep => BOOP
you must pass the return value of
var shoe = ;var express =var app =var sock = ;// *** must pass expcess/connect apps like this:sock;
you can use reconnect just in case your sock ends or gets disconnected.
var shoe = ;var reconnect = ;var es = ;var result = document;var r =
var shoe =
Return a readable/writable stream from the sockjs path
uri may be a full uri or just a path.
shoe will emit a
'connect' event when the connection is actually open,
(just like in net).
writes performed before the
'connect' event will be buffered. passing in
shoe is a shortcut for
var shoe =
All the methods from the sockjs exports objects are attached onto the
function, but the
shoe() function itself is special.
Create a server with
sockjs.createServer(opts) except this function also adds
.install() function below.
cb is specified, it fires
sock.installHandler() with the default option of spamming stdout with log
messages switched off in place of just emitting
sock object instead. This is a much less spammy default that gets out
of your way.
opts is a string, use it as the
All the messages that sockjs normally emits will be available on the
object plus the events below:
Using the default logger with
sock.install() will cause these
to be emitted instead of spamming stdout.
With npm do:
npm install shoe