Wicket 页面中的更多 WebSocket 连接
More WebSocket connections in a Wicket page
我正在尝试在我们的 Wicket 应用程序中实现一些 WebSocket 相关代码。有件事我不明白。如何在单个页面中创建更多连接?
查看文档:
When a client is connected it is being registered in a application scoped registry using as a key the application name, the client http session id, and the id of the page or the resource name that registered it. Later when the server needs to push a message it can use this registry to filter out which clients need to receive the message.
和
By adding a (Base)WebSocketBehavior to your component(s) Wicket will contribute wicket-websocket-jquery.js library which provides some helper functions to write your client side code. There is a default websocket connection per Wicket Page opened for you which you can use like:
Wicket.WebSocket.send('{msg: "my message"}');
If you need more WebSocket connections then you can do:
var ws = new Wicket.WebSocket();
ws.send('message');
如果我使用 new Wicket.WebSocket()
方法,我以后如何从连接注册表中获取已注册的连接? IWebSocketConnectionRegistry
允许通过由 Application、sessionId 和 pageId 组成的密钥获取连接。
默认WebSocketConnectionRegistry 仅支持一个按键连接,但您可以使用自己的注册表实现为每个按键创建一个列表。
为什么需要二次连接?通常一个应用程序只需要一个连接并使用响应消息的结构(例如 JSON 和一些区分键)来决定如何在浏览器中处理它。
我正在尝试在我们的 Wicket 应用程序中实现一些 WebSocket 相关代码。有件事我不明白。如何在单个页面中创建更多连接?
查看文档:
When a client is connected it is being registered in a application scoped registry using as a key the application name, the client http session id, and the id of the page or the resource name that registered it. Later when the server needs to push a message it can use this registry to filter out which clients need to receive the message.
和
By adding a (Base)WebSocketBehavior to your component(s) Wicket will contribute wicket-websocket-jquery.js library which provides some helper functions to write your client side code. There is a default websocket connection per Wicket Page opened for you which you can use like:
Wicket.WebSocket.send('{msg: "my message"}');
If you need more WebSocket connections then you can do:
var ws = new Wicket.WebSocket();
ws.send('message');
如果我使用 new Wicket.WebSocket()
方法,我以后如何从连接注册表中获取已注册的连接? IWebSocketConnectionRegistry
允许通过由 Application、sessionId 和 pageId 组成的密钥获取连接。
默认WebSocketConnectionRegistry 仅支持一个按键连接,但您可以使用自己的注册表实现为每个按键创建一个列表。
为什么需要二次连接?通常一个应用程序只需要一个连接并使用响应消息的结构(例如 JSON 和一些区分键)来决定如何在浏览器中处理它。