JedWatson/keystone — pull request #406 by killerbobjr (2014-06-07 13:24:10+00:00)
Title: Exposes session key, session store, and session cookie parser

The allows the use of session.socket.io which matches a socket.io connection with a corresponding express session.

There is no dependency on any specific implementations/versions of either express or socket.io.

A simple example using session.socket.io with keystone:

keystone.start(
{
onHttpServerCreated: function()
{
keystone.app.io = require('socket.io').listen(keystone.httpServer);
keystone.app.sessionsocketio = new require('session.socket.io')(keystone.app.io, keystone.app.sessionOpts.store, keystone.app.sessionOpts.cookieParser, keystone.app.sessionOpts.key);
keystone.app.sessionsocketio.on('connection', function (err, socket, session) {
socket.emit('alert', { message: 'socket.io is connected to session: ' + session });
});
}
});

Example html using the latest socket.io v1.x: