I really like the direction the team is working on primus , because there is currently a lot of rejection in socket implementations. They allow you to freely switch between several of the most popular websocket libraries (including sockJS) without additional code.
You can use primus with the rooms community plugin to accomplish what you are trying to do.
The plugin will allow you to do something like this:
spark.room('news').write( { hello : 'world' } );
A spark works much like a socket. Whenever a primus receives a connection, it gives you a spark object to manipulate. So here is a complete example:
var Primus = require('primus')
, http = require('http');
var server = http.createServer()
, primus = new Primus(server, { transformer: 'sockjs' });
primus.on('connection', function (spark) {
spark.room('news').write( { hello : 'world' } );
});
, sockJS primus. , .
ws primus, . RFC 6455 , .
0
, :
, primus , API- primus. http-, html:
// use this to load the client-side framework in development only
<script src="/primus/primus.js"></script>
, , , primus .
, / , , . .