The sever push is a common practice to allow the inline frames to communicate with each other. While the server push is general and not limited to inter-communication among inline frames, it introduced some extra overhead to the network traffic (no matter comet or client-polling is used).

With 5.0.4, we introduce a concept called group, and a new event queue called the group-scoped event queue. By group we mean a collection of browser windows (mostly inline frames) whose top window is the same. For example, there is five windows belong to the same group in Demo of Portal Layout: the main window and four Portal channels.

The use of the group-scoped event queue is the same as other event queues, except specifying "group" as the scope. For example, here is the code snippet implementing a chat function to post events to all desktops of the browser windows belonging the same group of browser windows.


<zscript>
	EventListener el;
	EventQueue que = EventQueues.lookup("groupTest", "group", true);
	que.subscribe(el = new EventListener() {
		public void onEvent(Event evt) {
			o.setValue(o.getValue() + evt.getData() + "\n");
		}
	});
	void publish() {
		String text = i.getValue();
		if (text.length() > 0) {
			i.setValue("");
			que.publish(new Event("onGroupTest", null, text));
		}
	}
</zscript>
<textbox id="i" onChange="publish()"/>		
<textbox id="o" rows="6"/>

Like the user of any kind of event queues, what you need to subscribe an event listener, and then listen to the event you care. ZK won’t use any server push for the group-scoped event queue. Rather, it uses Ajax requests and sends them only if there is an event published to the event queue.

Example:
Example of Group-scoped Event Queue
Download: ZK 5.0.4 EE Freshly
Notice that it is a freshly release (not official) and available only in ZK EE.

If you enjoyed this post, please consider leaving a comment or subscribing to the RSS feed to have future articles delivered to your feed reader.

Leave a Reply