Revision history [back]

click to hide/show revision 1
initial version

answered 2016-11-17 02:02:01 +0800

cor3000 gravatar image cor3000

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
    }
});

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
    }
});
Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More