In ZK 8.5, there is a new session, where a WebSocket-based update engine is introduced to handle requests if the browser is supported.
The advantage of WebSocket (over AJAX), is once the connection has been established, all future messages are passed over the socket rather than new HTTP request/response calls.
We support not only WebSocket-based Update Engine, but also a WebSocket-based server push. This reduces the count of http connections when there is a huge amount of updates.
In the first clip, we can see when the ajax-based ZK update engine is on, numerous requests will be established. While in the second clip, with websocket based ZK update engine, there is only one connection established; even if we enable server push, less HTTP overhead.
- ZK: 8.5.0.FL.20170725-Eval or later
- Browser: Internet Explorer 10+, Edge, Firefox, Chrome, Safari, iOS Safari, Android Browser, Opera
<!-- required -->
<!-- optional -->
- Line 2 to 4: It is required to add a configuration
org.zkoss.zkmax.au.websocket.WebSocketWebAppInit to enable the WebSocket connection.
- Line 6 to 9: Map the url pattern for WebSocket connection; if this library property is not configured,
/zkwm will be used by default.
Be noted that
WebSocketServerPush will be the selected server push class if the WebSocket connection is on, even though other server push class is configured in
The whole demo project can be found on Github project.