-
1. Re: Best way to detect user presence
fvitorc Feb 9, 2012 12:56 AM (in response to fvitorc)Actually, it's not possible to listen to incoming messages on the ServerBus. I get the following exception if I try to do so:
java.lang.IllegalArgumentException: cannot modify or subscribe to reserved service: ServerBus
So I would like to request a new feature for errai. The proposal would be to get queue connect/disconnect events.
The end user could write something like that to get these events:
@QueuePresence
public class MyQueuePresence implements QueuePresenceListener {
@Override
public void onConnect(String sessionId) {
// do whatever I want
}
@Override
public void onDisconnect(String sessionId) {
// do whatever I want
}
}
Of course, the interface, annotation and methods names could be different.
Where can I request such feature? Is it writing in this forum enough?
Regards,
Vitor.
-
2. Re: Best way to detect user presence
fvitorc Feb 11, 2012 1:52 PM (in response to fvitorc)After a while, I found a solution for that. For disconnects it's quite simple, but for connects you must disable the monitor tool.
Anyway, the ServerMessageBusImpl (just cast to it from a MessageBus) has a addQueueClosedListener for disconnects.
It also has a attachMonitor method, which provides not only connect/disconnect events, but a lot of other notifications.
The bad part is that you won't be able to use the monitor tool, because only one monitor can be active at a time.
I believe the best thing to do then, is to initially send your own connect message (do not rely on ServerBus), and use a QueueClosedListener for disconnects.
Regards,
Vitor.