use of org.apache.wicket.protocol.ws.WebSocketSettings in project wicket by apache.
the class WebSocketPushBroadcaster method process.
private void process(final Application application, final Collection<IWebSocketConnection> wsConnections, final IWebSocketPushMessage message) {
WebSocketSettings webSocketSettings = WebSocketSettings.Holder.get(application);
Executor executor = webSocketSettings.getWebSocketPushMessageExecutor();
for (final IWebSocketConnection wsConnection : wsConnections) {
executor.run(new Runnable() {
@Override
public void run() {
wsConnection.sendMessage(message);
}
});
}
}
use of org.apache.wicket.protocol.ws.WebSocketSettings 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);
}
use of org.apache.wicket.protocol.ws.WebSocketSettings in project wicket by apache.
the class BaseWebSocketBehavior method renderHead.
@Override
public void renderHead(Component component, IHeaderResponse response) {
super.renderHead(component, response);
response.render(JavaScriptHeaderItem.forReference(WicketWebSocketJQueryResourceReference.get()));
PackageTextTemplate webSocketSetupTemplate = new PackageTextTemplate(WicketWebSocketJQueryResourceReference.class, "res/js/wicket-websocket-setup.js.tmpl");
Map<String, Object> variables = Generics.newHashMap();
// set falsy JS values for the non-used parameter
if (Strings.isEmpty(resourceName)) {
int pageId = component.getPage().getPageId();
variables.put("pageId", pageId);
variables.put("resourceName", "");
} else {
variables.put("resourceName", resourceName);
variables.put("pageId", false);
}
WebSocketSettings webSocketSettings = WebSocketSettings.Holder.get(component.getApplication());
CharSequence baseUrl = getBaseUrl(webSocketSettings);
Args.notNull(baseUrl, "baseUrl");
variables.put("baseUrl", baseUrl);
Integer port = getPort(webSocketSettings);
variables.put("port", port);
Integer securePort = getSecurePort(webSocketSettings);
variables.put("securePort", securePort);
CharSequence contextPath = getContextPath(webSocketSettings);
Args.notNull(contextPath, "contextPath");
variables.put("contextPath", contextPath);
// preserve the application name for JSR356 based impl
variables.put("applicationName", component.getApplication().getName());
CharSequence filterPrefix = getFilterPrefix(webSocketSettings);
Args.notNull(filterPrefix, "filterPrefix");
variables.put("filterPrefix", filterPrefix);
final CharSequence sessionId = getSessionId(component);
variables.put("sessionId", sessionId);
String webSocketSetupScript = webSocketSetupTemplate.asString(variables);
response.render(OnDomReadyHeaderItem.forScript(webSocketSetupScript));
}
use of org.apache.wicket.protocol.ws.WebSocketSettings in project openmeetings by apache.
the class WebSocketHelper method sendClient.
private static void sendClient(IWsClient client, Consumer<IWebSocketConnection> wsc) {
Application app = (Application) getApp();
WebSocketSettings settings = WebSocketSettings.Holder.get(app);
IWebSocketConnectionRegistry reg = settings.getConnectionRegistry();
// FIXME TODO
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);
});
}
}
Aggregations