jarmo-socket.io
v0.1.3
Published
Socket.IO middleware for Jarmo.
Downloads
7
Readme
Jarmo Socket.IO
Socket.IO middleware for Jarmo.
Configuration
Taken directly from the source:
/**
* @param {object} config
* @param {string} config.host Host of the Jarmo server.
* @param {number} config.port Port of the Jarmo server.
* @param {function} config.onError Error handling function.
* @param {function} config.onConnect The payload resolving function for
* when a client connects.
* @param {function} config.onDisconnect The payload resolving function for
* when a client disconnects.
*/
The configuration is very similar to jarmo-express,
however here you have two separate payload resolvers, for both connect
and
disconnect
events. Similarly to jarmo-express, you
must set the JARMO_ENABLE
environmental variable for this to actually work.
Example
var io = require('socket.io')();
var jarmo = require('jarmo-socket.io');
function onConnect(socket, numConn) {
return {
n_connections: numConn
}
}
server.use(jarmo({ onConnect: onConnect }));
// ...
server.listen(process.env.PORT);