serverless-artillery
Version:
A serverless performance testing tool. `serverless` + `artillery` = crush. a.k.a. Orbital Laziers [sic]
75 lines (52 loc) • 1.94 kB
Markdown
socketio-wildcard
=================
[](https://travis-ci.org/hden/socketio-wildcard)
[](https://david-dm.org/hden/socketio-wildcard)
[](https://david-dm.org/hden/socketio-wildcard#info=devDependencies)
[](https://www.npmjs.com/package/socketio-wildcard)
[](http://standardjs.com/)
[](https://nodei.co/npm/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`.
Installation
------------
npm install --save socketio-wildcard
Usage
-----
### Server
```js
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);
```
### Client
```js
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(){ /* … */ })
```
Changelog
---------
### [2.0.0] - 2016-05-23
- no breaking change
- update test dependencies for socket.io v2
### [0.3.0] - 2015-12-21
- allow custom event emitter
- support socket.io client
### [0.2.0] - 2015-11-29
- wildcard listener for all events get called first ([@Michael77](https://github.com/Michael77))
- removed coffee-script dependency
Licence
-------
MIT