Pattern Matching Events
Events can now be matched via RegExp
and wildcards.
var router = require('socket.io-events')();
router.on(/^\w+/, function (sock, args, next) {
// do something but don't consume it!
next();
});
router.on('*thing', function (sock, args, next) {
// do something but don't consume it!
next();
});
router.on('some*', function (sock, args, next) {
// do something but don't consume it!
next();
});
var io = require('socket.io')(3000);
io.use(router);
io.on('connection', function (sock) {
sock.on('something', function (data) {
sock.emit('something', data);
});
});