Example usage for org.apache.wicket.protocol.ws WebSocketSettings getWebSocketPushMessageExecutor

List of usage examples for org.apache.wicket.protocol.ws WebSocketSettings getWebSocketPushMessageExecutor

Introduction

In this page you can find the example usage for org.apache.wicket.protocol.ws WebSocketSettings getWebSocketPushMessageExecutor.

Prototype

public Executor getWebSocketPushMessageExecutor() 

Source Link

Usage

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   ww  w . ja v  a  2 s . c  o m
}

From source file:org.apache.openmeetings.core.util.WebSocketHelper.java

License:Apache License

private static void sendAll(Consumer<IWebSocketConnection> sender) {
    new Thread(() -> {
        Application app = (Application) getApp();
        if (app == null) {
            return; // Application is not ready
        }/*  w  ww  .ja  va2 s. co m*/
        WebSocketSettings settings = WebSocketSettings.Holder.get(app);
        IWebSocketConnectionRegistry reg = settings.getConnectionRegistry();
        Executor executor = settings.getWebSocketPushMessageExecutor();
        for (IWebSocketConnection c : reg.getConnections(app)) {
            executor.run(() -> sender.accept(c));
        }
    }).start();
}

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
        }/*from   w  ww  .  ja v a  2s.  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();
}