@Override public void start() throws Exception { Router router = Router.router(vertx); router.route("/news-feed/*").handler(SockJSHandler.create(vertx).socketHandler(sockJSSocket -> { // Consumer the event bus address as an Observable Observable<String> msg = vertx.eventBus().<String>consumer("news-feed") .bodyStream() .toObservable(); // Send the event to the client Subscription subscription = msg.subscribe(sockJSSocket::write); // Unsubscribe when the socket closes sockJSSocket.endHandler(v -> { subscription.unsubscribe(); }); })); // Serve the static resources router.route().handler(StaticHandler.create()); vertx.createHttpServer().requestHandler(router).listen(8080); // Publish a message to the address "news-feed" every second vertx.setPeriodic(1000, t -> vertx.eventBus().publish("news-feed", "news from the server!")); } }
public static SockJSSocket newInstance(io.vertx.ext.web.handler.sockjs.SockJSSocket arg) { return arg != null ? new SockJSSocket(arg) : null; } }
public static SockJSHandler newInstance(io.vertx.ext.web.handler.sockjs.SockJSHandler arg) { return arg != null ? new SockJSHandler(arg) : null; } }
public void handle(io.vertx.ext.web.handler.sockjs.SockJSSocket event) { handler.handle(io.vertx.rxjava.ext.web.handler.sockjs.SockJSSocket.newInstance(event)); } });
/** * Something has happened, so handle it. * @param event the event to handle */ public void handle(io.vertx.rxjava.ext.web.handler.sockjs.SockJSSocket event) { delegate.handle(event.getDelegate()); }
public static BridgeEvent newInstance(io.vertx.ext.web.handler.sockjs.BridgeEvent arg) { return arg != null ? new BridgeEvent(arg) : null; } }
public void handle(io.vertx.ext.web.handler.sockjs.BridgeEvent event) { bridgeEventHandler.handle(io.vertx.rxjava.ext.web.handler.sockjs.BridgeEvent.newInstance(event)); } });
/** * Create a SockJS handler * @param vertx the Vert.x instance * @return the handler */ public static io.vertx.rxjava.ext.web.handler.sockjs.SockJSHandler create(io.vertx.rxjava.core.Vertx vertx) { io.vertx.rxjava.ext.web.handler.sockjs.SockJSHandler ret = io.vertx.rxjava.ext.web.handler.sockjs.SockJSHandler.newInstance(io.vertx.ext.web.handler.sockjs.SockJSHandler.create(vertx.getDelegate())); return ret; }
/** * Set a handler for the result. * <p> * If the future has already been completed it will be called immediately. Otherwise it will be called when the * future is completed. * @return a reference to this, so it can be used fluently */ public Single<Boolean> rxSetHandler() { return Single.create(new io.vertx.rx.java.SingleOnSubscribeAdapter<>(fut -> { setHandler(fut); })); }
public void handle(io.vertx.ext.web.handler.sockjs.SockJSSocket event) { handler.handle(io.vertx.rxjava.ext.web.handler.sockjs.SockJSSocket.newInstance(event)); } });
public synchronized io.vertx.rx.java.WriteStreamSubscriber<io.vertx.rxjava.core.buffer.Buffer> toSubscriber() { if (subscriber == null) { java.util.function.Function<io.vertx.rxjava.core.buffer.Buffer, io.vertx.core.buffer.Buffer> conv = io.vertx.rxjava.core.buffer.Buffer::getDelegate; subscriber = io.vertx.rx.java.RxHelper.toSubscriber(getDelegate(), conv); } return subscriber; }
public static SockJSSocket newInstance(io.vertx.ext.web.handler.sockjs.SockJSSocket arg) { return arg != null ? new SockJSSocket(arg) : null; } }
public static SockJSHandler newInstance(io.vertx.ext.web.handler.sockjs.SockJSHandler arg) { return arg != null ? new SockJSHandler(arg) : null; } }
public static BridgeEvent newInstance(io.vertx.ext.web.handler.sockjs.BridgeEvent arg) { return arg != null ? new BridgeEvent(arg) : null; } }
public void handle(io.vertx.ext.web.handler.sockjs.BridgeEvent event) { bridgeEventHandler.handle(io.vertx.rxjava.ext.web.handler.sockjs.BridgeEvent.newInstance(event)); } });
/** * Create a SockJS handler * @param vertx the Vert.x instance * @param options options to configure the handler * @return the handler */ public static io.vertx.rxjava.ext.web.handler.sockjs.SockJSHandler create(io.vertx.rxjava.core.Vertx vertx, SockJSHandlerOptions options) { io.vertx.rxjava.ext.web.handler.sockjs.SockJSHandler ret = io.vertx.rxjava.ext.web.handler.sockjs.SockJSHandler.newInstance(io.vertx.ext.web.handler.sockjs.SockJSHandler.create(vertx.getDelegate(), options)); return ret; }
/** * Get the SockJSSocket instance corresponding to the event * @return the SockJSSocket instance */ public io.vertx.rxjava.ext.web.handler.sockjs.SockJSSocket socket() { if (cached_1 != null) { return cached_1; } io.vertx.rxjava.ext.web.handler.sockjs.SockJSSocket ret = io.vertx.rxjava.ext.web.handler.sockjs.SockJSSocket.newInstance(delegate.socket()); cached_1 = ret; return ret; }
public synchronized io.vertx.rx.java.WriteStreamSubscriber<io.vertx.rxjava.core.buffer.Buffer> toSubscriber() { if (subscriber == null) { java.util.function.Function<io.vertx.rxjava.core.buffer.Buffer, io.vertx.core.buffer.Buffer> conv = io.vertx.rxjava.core.buffer.Buffer::getDelegate; subscriber = io.vertx.rx.java.RxHelper.toSubscriber(getDelegate(), conv); } return subscriber; }
/** * Get the SockJSSocket instance corresponding to the event * @return the SockJSSocket instance */ public io.vertx.rxjava.ext.web.handler.sockjs.SockJSSocket socket() { if (cached_1 != null) { return cached_1; } io.vertx.rxjava.ext.web.handler.sockjs.SockJSSocket ret = io.vertx.rxjava.ext.web.handler.sockjs.SockJSSocket.newInstance(delegate.socket()); cached_1 = ret; return ret; }
/** * Something has happened, so handle it. * @param event the event to handle */ public void handle(io.vertx.rxjava.ext.web.handler.sockjs.SockJSSocket event) { delegate.handle(event.getDelegate()); }