Live.io combines the power of the new Express 4.0, socket.io and passport! Empower your sockets!
npm install live.io --save
replace require('express') with require('live.io')
Initialization params
- sessionSecret - your express-session secret. Required field.
- store - session store. Defaults to MemoryStore of express-session package.
- cookieParser - your custom cookie-parser. Defaults to cookie-parser package.
- Secure - If you use https, wss combo, you can pass your https options. Note: If you use secure, socket-io will be secure-only.
var app = live({
sessionSecret: sessionSecret,
store: sessionStore,
cookieParser: cookieParser,
secure: {
key: privateKey,
cert: certificate
}
});
Add your socket route using the socket method.
app.route('/').socket(function(req, res){
// req.body contains socket data
// res.emit can emit data to socket.
// res.json is a helper method to return json data. This will be implemented in the next release.
});
Special events include 'connect' and 'disconnect' while routing.
app.route('connect').socket(function(req, res){
// do stuff on connection.
});
app.route('disconnect').socket(function(req, res){
// do stuff on connection.
});
grunt test
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code.
- 0.0.1 Initial release