I resolved by using chuckt.
npm install chuckt
In the source code of the server:
var sockjs = require('sockjs');
var chuckt = require('chuckt');
var sock = sockjs.createServer();
sock.on('connection', function(conn) {
var chuckt = new ChuckT(conn);
// ... do chuckt stuff like add listeners or emit events
In the client:
<script src="chuckt.js"></script>
<script>
var sock = new SockJS('http://example.com/socket');
var chuckt = epixa.chucktify(sock);
</script>
Be careful that once
is not available at the moment in the client.