-
FEATURED COMPONENTS
First time here? Check out the FAQ!
1 | initial version | |
if you want to notify all users on the server you need to lookup/create an application scoped event queue.
EventQueue eq = EventQueues.lookup("testqueue", "application", true);
It is allowed to publish events) to an application (or session) scoped event queue outside an execution.
Here also a short example: If you open this in multiple browsers you'll see how every browser (=different user): receives a notification after a new user joined. The background thread can be any kind of thread. All it needs is a reference to the eventqueue in order to publish events.
EventQueue eq = EventQueues.lookup("testqueue", "application", true);
Thread a = new Thread() {
public void run() {
org.zkoss.lang.Threads.sleep(5000);
eq.publish(new Event("onMyEvent", null, "some_redirect_url"));
}
};
a.start();
eq.subscribe(new EventListener() {
public void onEvent(Event evt) {
alert(evt.getData());
//open your popup based on the url
}
});
2 | No.2 Revision |
if you want to notify all users on the server you need to lookup/create an application scoped event queue.
EventQueue eq = EventQueues.lookup("testqueue", "application", true);
It is allowed to publish events) to an application (or session) scoped event queue outside an execution.
Here also a short example: If you open this in multiple browsers you'll see how every browser (=different user): receives a notification after a new user joined. The background thread can be any kind of thread. All it needs is a reference to the eventqueue in order to publish events.
EventQueue eq = EventQueues.lookup("testqueue", "application", true);
Thread a = new Thread() {
public void run() {
org.zkoss.lang.Threads.sleep(5000);
eq.publish(new Event("onMyEvent", null, "some_redirect_url"));
}
};
a.start();
eq.subscribe(new EventListener() {
public void onEvent(Event evt) {
alert(evt.getData());
//open your popup based on the url
}
});