Open
Description
Hello,
I'm using socket.io java client for my android application. My application (1) is a wrapper of another application (2) that listens to socket.io events. From the view of my wrapper application, I don't know the list of specific events that the application (2) listens to. However, I need to access to the returned params of the registered event handlers of the application (2).
Hence I wonder if we can add a special event, e.g. *
, that once it's registered by Emitter.on("*", callback)
, will transfer the response of all event to the *
event callback ?
Regarding to the source code, I found out that it's easy to do so by just adding some line of code in the Emitter
:
public Emitter emit(String event, Object... args) {
ConcurrentLinkedQueue<Listener> callbacks = this.callbacks.get(event);
if (callbacks != null) {
for (Listener fn : callbacks) {
fn.call(args);
}
}
// Emit to all event handlers if it is registered
ConcurrentLinkedQueue<Listener> allEventCallbacks = this.callbacks.get("*");
if (allEventCallbacks != null) {
for (Listener fn : allEventCallbacks) {
fn.call(event, args);
}
}
return this;
}
What do you think if it's possible to do that ?
Thanks for any help.