* There are no users in space, only astronauts with the latest browser. Therefore no graceful fallback is attempted.
var server = http.createServer(...);
server.listen(port);
require('spacesocket').attach(server, function(conn) {
dealWithWebSocket(conn);
});
conn.on('data', function(msg) {
doStuffWithString(msg);
});
conn.write('Hello, World');
conn.end();
conn.on('drain', function() {
// socket write queue is empty,
// send until queueing again:
while(conn.send(data)) { }
});
// Throttle sender for 1s:
conn.pause();
setTimeout(function() { conn.resume(); }, 1000);