Skip to content

Instantly share code, notes, and snippets.

@dhenson02
Created July 28, 2016 15:21
Show Gist options
  • Save dhenson02/0596fafc4f393bd01c1e33d09a2ca63c to your computer and use it in GitHub Desktop.
Save dhenson02/0596fafc4f393bd01c1e33d09a2ca63c to your computer and use it in GitHub Desktop.
var emit = commonjs.socket.emit.bind(commonjs.socket);
var onevent = commonjs.socket.onevent;
commonjs.socket.onevent = function ( packet ) {
var args = packet.data || [];
onevent.call(this, packet); // original call
packet.data = [ "*" ].concat(args);
onevent.call(this, packet); // additional call to catch-all
};
commonjs.socket.on("*", function ( event, data ) {
console.log(event);
console.log(data);
});
commonjs.socket.emit = function () {
console.log('emit', arguments);
return emit.apply(null, arguments)
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment