Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
S

socketio-wildcard

> 编程语言
Open source

socket.io v2.x with a wildcard event

198 stars0 likes0 views
WebsiteGitHub

About

socket.io v2.x with a wildcard event

socketio-wildcard

Socket.io with a wildcard event.

Works with Socket.io v1.x - v2.x.

Tested with node.js v8.x - v12.x.

Sunsetting

As of Socket.io v2.0.4 (commit), you can use a socket middleware to catch every incoming Packet, which satisfies most of socketio-wildcard's use cases.

javascript
io.on('connection', (socket) => {
  socket.use((packet, next) => {
    // Handler
    next();
  });
});

Installation

bash
npm install --save socketio-wildcard

Usage

Server

javascript
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);

Server (with a namespace)

diff
var io         = require('socket.io')();
+var nsp        = io.of('/namespace');
var middleware = require('socketio-wildcard')();

-io.use(middleware);
+nsp.use(middleware);

-io.on('connection', function(socket) {
+nsp.on('connection', function(socket) {
  socket.on('*', function(packet){
    // client.emit('foo', 'bar', 'baz')
    packet.data === ['foo', 'bar', 'baz']
  });
});

io.listen(8000);

Client

javascript
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)
  • removed coffee-script dependency

Licence

MIT

License

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

JavaScriptsocket-iosocketiosocketio-wildcard

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 18, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言