Search in sources :

Example 1 with WebSocketPushBroadcaster

use of org.apache.wicket.protocol.ws.api.WebSocketPushBroadcaster in project wicket by apache.

the class WebSocketTester method broadcast.

/**
 * Broadcasts/pushes a message to specific web socket connection
 *
 * @param application
 *          The application where the web socket connection is registered
 * @param sessionId
 *          The id of the http session with which the web socket connection is registered
 * @param key
 *          The key with which the web socket connection is registered
 * @param message
 *          The message to broadcast/push
 */
public void broadcast(Application application, String sessionId, IKey key, IWebSocketPushMessage message) {
    WebSocketSettings webSocketSettings = WebSocketSettings.Holder.get(application);
    WebSocketPushBroadcaster broadcaster = new WebSocketPushBroadcaster(webSocketSettings.getConnectionRegistry());
    ConnectedMessage wsMessage = new ConnectedMessage(application, sessionId, key);
    broadcaster.broadcast(wsMessage, message);
}
Also used : WebSocketSettings(org.apache.wicket.protocol.ws.WebSocketSettings) WebSocketPushBroadcaster(org.apache.wicket.protocol.ws.api.WebSocketPushBroadcaster) ConnectedMessage(org.apache.wicket.protocol.ws.api.message.ConnectedMessage)

Example 2 with WebSocketPushBroadcaster

use of org.apache.wicket.protocol.ws.api.WebSocketPushBroadcaster in project wicket by apache.

the class WebSocketTester method broadcastAll.

/**
 * Broadcasts/pushes a message to all active web socket connections
 *
 * @param application
 *          The application where the web socket connection is registered
 * @param message
 *          The message to broadcast/push
 */
public void broadcastAll(Application application, IWebSocketPushMessage message) {
    WebSocketSettings webSocketSettings = WebSocketSettings.Holder.get(application);
    WebSocketPushBroadcaster broadcaster = new WebSocketPushBroadcaster(webSocketSettings.getConnectionRegistry());
    broadcaster.broadcastAll(application, message);
}
Also used : WebSocketSettings(org.apache.wicket.protocol.ws.WebSocketSettings) WebSocketPushBroadcaster(org.apache.wicket.protocol.ws.api.WebSocketPushBroadcaster)

Aggregations

WebSocketSettings (org.apache.wicket.protocol.ws.WebSocketSettings)2 WebSocketPushBroadcaster (org.apache.wicket.protocol.ws.api.WebSocketPushBroadcaster)2 ConnectedMessage (org.apache.wicket.protocol.ws.api.message.ConnectedMessage)1