code to switch between excluding adding a framework to your package.json different frameworks build-in socket.io, engine.io, sockjs, websockets, browserchannel, but allows addition third party 5 Friday, October 18, 13
code to switch between excluding adding a framework to your package.json different frameworks build-in socket.io, engine.io, sockjs, websockets, browserchannel, but allows addition third party 5 stars, but growing steady star it on http://github.com/primus/primus 279 Friday, October 18, 13
interface keeps the core light, while maximizing developer flexibility different ways to stay connected online/offline detection, client side pings combined with different reconnect strategies 5 Friday, October 18, 13
interface keeps the core light, while maximizing developer flexibility different ways to stay connected online/offline detection, client side pings combined with different reconnect strategies 5 reasons on why you should use it fixes bugs in real-time frameworks, fixes websocket crashes, it has a cool name, node.js stream interface, an api that never changes ∞ Friday, October 18, 13
Primus = require(‘primus’) , http = require(‘http’); // Create a HTTP server, attach Primus, specify transformer & done var server = http.createServer() , primus = new Primus(server, { transformer: ‘websockets’ }); primus.on(‘connection’, function (spark) { spark.write(‘foo’); spark.write({ json: ‘also works’ }); spark.on(‘data’, function (data) { console.log(‘data’, data); }); // Sparks are streams, so pipe data. require(‘fs’).createReadStream(__dirname +’/index.js’).pipe(spark); }); server.listen(80); the server Friday, October 18, 13
primus = new Primus(‘http://localhost:8080?foo=bar', { // Options to further customize Primus. }); primus.on(‘data’, function (data) { console.log(‘received’, data); }); primus.on(‘end’, function () { console.log(‘connection end’); }); primus.write({ sending: 1337 }); primus.write(‘same syntax as node’); the client Friday, October 18, 13
critical features debug better performance biz integration scalability NIH MAINTENANCE OMG WHY ARE YOU USING COFFEESCRIPT latency Friday, October 18, 13
critical features debug better performance biz integration scalability NIH MAINTENANCE OMG WHY ARE YOU USING COFFEESCRIPT latency freedom Friday, October 18, 13
connections no packet loss work in hostile user environments AUTHENTICATION & HANDSHAKINGEXTENDABLE BY PLUGINS message encoding data transfer Friday, October 18, 13
high latency reliable connections no packet loss work in hostile user environments AUTHENTICATION & HANDSHAKINGEXTENDABLE BY PLUGINS message encoding data transfer Friday, October 18, 13
high latency reliable connections no packet loss work in hostile user environments AUTHENTICATION & HANDSHAKINGEXTENDABLE BY PLUGINS message encoding data transfer no code bloat Friday, October 18, 13
CONDITION HEARTBEATS no high latency reliable connections no packet loss work in hostile user environments AUTHENTICATION & HANDSHAKINGEXTENDABLE BY PLUGINS message encoding data transfer no code bloat Friday, October 18, 13
CONDITION HEARTBEATS no high latency reliable connections no packet loss CROSS BROWSER PLATFORM DOMAIN / / work in hostile user environments AUTHENTICATION & HANDSHAKINGEXTENDABLE BY PLUGINS message encoding data transfer no code bloat Friday, October 18, 13
and security software mangle headers again, use secure connections to obfuscate the connection from this software, use regular expressions or direct gzip detection Accept-EncodXng: gzip, deflate X-cept-Encoding: gzip, deflate XXXXXXXXXXXXXXX: XXXXXXXXXXXXX ---------------: ------------- ~~~~~~~~~~~~~~~: ~~~~~~~~~~~~~ source: http://developer.yahoo.com/blogs/ydn/pushing-beyond-gzipping-25601.html Friday, October 18, 13
retrieving initial state from server or other data that is needed to give the connection it’s initial state and saves an extra poll request Friday, October 18, 13
use multiple subdomains / hosts no open source framework implements this, but has been solved for ages this can also be used for load balancing when done correctly Friday, October 18, 13
leverage native pings when available websockets have ping/pong protocols which are optimised for this, no api for the browser :( because they didn’t find it useful enough and that it should be implemented by browser vendors (which didn’t implement it) Friday, October 18, 13
things their here to assist you, instead of haunt you sandbox your library with the most under estimated technology currently available on the web actually... Friday, October 18, 13
one single bug can take down your connection watch my previous talks about websuckets and their issues - enough to fill a single talk Friday, October 18, 13
stream no flow control library can beat stream#pipe yes, I know, streams are slow… but usability & maintenance wins over performance every day ™ Friday, October 18, 13
all cost stop creating new objects, pool & reuse this is a serious pain point for node.js and real-time.. you might even be better of with erlang Friday, October 18, 13