$ cnpm install socketio-wildcard
Socket.io with a wildcard event.
Works with Socket.io v1.x - v2.x.
Tested with node.js v4.x, v5.x, v6.x, v7.x.
npm install --save socketio-wildcard
var io = require('socket.io')();
var middleware = require('socketio-wildcard')();
io.use(middleware);
io.on('connection', function(socket) {
socket.on('*', function(packet){
// client.emit('foo', 'bar', 'baz')
packet.data === ['foo', 'bar', 'baz']
});
});
io.listen(8000);
var io = require('socket.io-client');
var socket = io('http://localhost');
// piggyback using the event-emitter bundled with socket.io client
var patch = require('socketio-wildcard')(io.Manager);
patch(socket);
socket.on('*', function(){ /* … */ })
MIT
Copyright 2013 - present © cnpmjs.org | Home |