Example usage for org.apache.wicket.protocol.ws.concurrent Executor run

List of usage examples for org.apache.wicket.protocol.ws.concurrent Executor run

Introduction

In this page you can find the example usage for org.apache.wicket.protocol.ws.concurrent Executor run.

Prototype

void run(Runnable command);

Source Link

Document

Runs a simple task that doesn't return a result

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));
    }/*  w w  w. j  av  a 2 s .  co  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 w  w. j ava2s. c  o 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
        }//  ww w .j a v a  2  s  .c om
        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();
}