A collection of middlewares for Socket.IO
JavaScript
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib fix style Jun 5, 2014
test fix style Jun 5, 2014
.gitignore initial commit Jul 7, 2013
.npmignore initial commit Jul 7, 2013
.travis.yml test on node v0.11 Apr 14, 2014
LICENSE initial commit Jul 7, 2013
README.md update README Jun 5, 2014
index.js initial commit Jul 7, 2013
package.json bump modules Jun 5, 2014

README.md

Socket.IO-bundle

Build Status

This is a collection of commonly used middlewares for Socket.IO, which I wish Socket.IO was bundled with. Socket.IO-bundle is based on Express middlewares, so that you can easily integrate with Express and Connect.

var bundle = require('socket.io-bundle');
var server = require('http').Server();
var io = require('socket.io')(server);

io.use(bundle.cookieParser());
io.use(bundle.session({secret: 'my secret here'}));
io.use(bundle.csrf());

server.listen(3000);

Arguments for each middlewares are completely the same with Express's ones. You must be aware of that session middleware can’t set cookies to clients due to the behavior of Socket.I.

CSRF

Csrf tokens will be supplied to browsers via Express/Connect, and be sent to a Socket.IO server as a query parameter.

// client
var socket = io('http://localhost:3000?_csrf=' + encodeURIComponent(_csrf));

License

MIT