List of usage examples for org.apache.wicket.protocol.ws.api.registry PageIdKey PageIdKey
public PageIdKey(Integer pageId)
From source file:org.apache.openmeetings.core.util.WebSocketHelper.java
License:Apache License
private static void sendClient(IWsClient client, Consumer<IWebSocketConnection> wsc) { Application app = (Application) getApp(); WebSocketSettings settings = WebSocketSettings.Holder.get(app); IWebSocketConnectionRegistry reg = settings.getConnectionRegistry(); Executor executor = settings.getWebSocketPushMessageExecutor(); final IWebSocketConnection wc = reg.getConnection(app, client.getSessionId(), new PageIdKey(client.getPageId())); if (wc != null && wc.isOpen()) { executor.run(() -> wsc.accept(wc)); }//from w ww.j a v a 2 s . com }
From source file:org.apache.openmeetings.core.util.WebSocketHelper.java
License:Apache License
static void send(final Function<Application, Collection<Client>> func, BiConsumer<IWebSocketConnection, Client> consumer, Predicate<Client> check) { new Thread(() -> { Application app = (Application) getApp(); if (app == null) { return; // Application is not ready }// ww w. ja v a 2 s .c o m WebSocketSettings settings = WebSocketSettings.Holder.get(app); IWebSocketConnectionRegistry reg = settings.getConnectionRegistry(); Executor executor = settings.getWebSocketPushMessageExecutor(); for (Client c : func.apply(app)) { if (check == null || check.test(c)) { final IWebSocketConnection wc = reg.getConnection(app, c.getSessionId(), new PageIdKey(c.getPageId())); if (wc != null && wc.isOpen()) { executor.run(() -> consumer.accept(wc, c)); } } } }).start(); }
From source file:org.apache.openmeetings.web.user.ChatPanel.java
License:Apache License
private static void sendRoom(ChatMessage m, String msg) { IWebSocketConnectionRegistry reg = WebSocketSettings.Holder.get(Application.get()).getConnectionRegistry(); for (Client c : getRoomUsers(m.getToRoom().getId())) { try {/* ww w. j av a 2s . co m*/ if (!m.isNeedModeration() || (m.isNeedModeration() && c.hasRight(Client.Right.moderator))) { IWebSocketConnection con = reg.getConnection(Application.get(), c.getSessionId(), new PageIdKey(c.getPageId())); if (con != null) { con.sendMessage(msg); } } } catch (Exception e) { log.error("Error while sending message to room", e); } } }