In Node.js is there any way to listen to all events emitted by an EventEmitter object?
e.g., can you do something like...
event_emitter.on(\
You might want to look into RPC modules for node.js. If I am not mistaken the Dnode RPC module has an chat server/client example similar to what you are trying to do. So you could either make use of their module or copy what they are doing.
In brief the example shows a server which on connection creates listeners for all the server events from the connected client. It does this by simply iterating over a stored list of event names.
var evNames = [ 'joined', 'said', 'parted' ];
con.on('ready', function () {
evNames.forEach(function (name) {
emitter.on(name, client[name]);
});
emitter.emit('joined', client.name);
});
This code is clever because it automatically calls a remote procedure call on the client associated with the event when the event is emitted.