public void handle(SockJSSocket sock) { connections.add(sock.writeHandlerID()); sock.handler(buffer -> { for (String actorID : connections) { vertx.eventBus().publish(actorID, buffer); } }); sock.endHandler(v -> connections.remove(sock.writeHandlerID())); } }));
/** * When a <code>SockJSSocket</code> is created it automatically registers an event handler with the event bus, the ID of that * handler is given by <code>writeHandlerID</code>. * <p> * Given this ID, a different event loop can send a buffer to that event handler using the event bus and * that buffer will be received by this instance in its own event loop and written to the underlying socket. This * allows you to write data to other sockets which are owned by different event loops. * @return */ public String writeHandlerID() { String ret = delegate.writeHandlerID(); return ret; }
/** * When a <code>SockJSSocket</code> is created it automatically registers an event handler with the event bus, the ID of that * handler is given by <code>writeHandlerID</code>. * <p> * Given this ID, a different event loop can send a buffer to that event handler using the event bus and * that buffer will be received by this instance in its own event loop and written to the underlying socket. This * allows you to write data to other sockets which are owned by different event loops. * @return */ public String writeHandlerID() { String ret = delegate.writeHandlerID(); return ret; }
public void handle(SockJSSocket sock) { connections.add(sock.writeHandlerID()); sock.handler(buffer -> { for (String actorID : connections) { vertx.eventBus().publish(actorID, buffer); } }); sock.endHandler(v -> connections.remove(sock.writeHandlerID())); } }));