/** * Configures the action to execute when a <code>ACK</code> frame is received. * @param handler the handler * @return the current {@link io.vertx.rxjava.ext.stomp.StompServerHandler} */ public io.vertx.rxjava.ext.stomp.StompServerHandler ackHandler(Handler<io.vertx.rxjava.ext.stomp.ServerFrame> handler) { delegate.ackHandler(new Handler<io.vertx.ext.stomp.ServerFrame>() { public void handle(io.vertx.ext.stomp.ServerFrame event) { handler.handle(io.vertx.rxjava.ext.stomp.ServerFrame.newInstance(event)); } }); return this; }
/** * Configures the STOMP server to act as a bridge with the Vert.x event bus. * @param options the configuration options * @return the current {@link io.vertx.rxjava.ext.stomp.StompServerHandler}. */ public io.vertx.rxjava.ext.stomp.StompServerHandler bridge(BridgeOptions options) { delegate.bridge(options); return this; }
/** * Configures the action to execute when a connection with the client is closed. * @param handler the handler * @return the current {@link io.vertx.rxjava.ext.stomp.StompServerHandler} */ public io.vertx.rxjava.ext.stomp.StompServerHandler closeHandler(Handler<io.vertx.rxjava.ext.stomp.StompServerConnection> handler) { delegate.closeHandler(new Handler<io.vertx.ext.stomp.StompServerConnection>() { public void handle(io.vertx.ext.stomp.StompServerConnection event) { handler.handle(io.vertx.rxjava.ext.stomp.StompServerConnection.newInstance(event)); } }); return this; }
public TrackingStompServer(Vertx vertx, int port) { StompServerHandler stompServerHandler = StompServerHandler.create(vertx); stompServerHandler.connectHandler(this::handleConnect); stompServerHandler.subscribeHandler(this::handleSubscribe); stompServerHandler.ackHandler(this::handleAck); stompServerHandler.closeHandler(this::handleClose); this.server = StompServer.create(vertx) .handler(stompServerHandler) .listen(port, "0.0.0.0", event -> { if (event.cause() == null) { listenFuture.complete(null); } else { listenFuture.completeExceptionally(event.cause()); } }); }
private void replayChunk(StompServerConnection connection, List<Frame> frames) { final List<Destination> destinations = connection.handler().getDestinations(); for (Frame frame : frames) { switch (frame.getCommand()) { case SEND: // We are sure that the destination is set, as the check is made before enqueuing the frame. String destination = frame.getHeader(Frame.DESTINATION); Destination dest = connection.handler().getDestination(destination); if (dest != null) { dest.dispatch(connection, frame); } break; case ACK: for (Destination d : destinations) { if (d.ack(connection, frame)) { break; } } break; case NACK: for (Destination d : destinations) { if (d.nack(connection, frame)) { break; } } break; } } } }
/** * @return the list of destination managed by the STOMP server. Don't forget the STOMP interprets destination as opaque Strings. */ public List<io.vertx.rxjava.ext.stomp.Destination> getDestinations() { List<io.vertx.rxjava.ext.stomp.Destination> ret = delegate.getDestinations().stream().map(elt -> io.vertx.rxjava.ext.stomp.Destination.newInstance(elt)).collect(java.util.stream.Collectors.toList()); return ret; }
for (Destination dest : connection.handler().getDestinations()) { List<String> ids = dest.getSubscriptions(connection); count += ids.size(); final Destination dest = connection.handler().getOrCreateDestination(destination); if (dest != null) { if (dest.subscribe(connection, frame) == null) {
/** * Something has happened, so handle it. * @param event the event to handle */ public void handle(io.vertx.rxjava.ext.stomp.ServerFrame event) { delegate.handle(event.getDelegate()); }
/** * Method called by single message (client-individual policy) or a set of message (client policy) are acknowledged. * Implementations must call the handler configured using {@link io.vertx.rxjava.ext.stomp.StompServerHandler#onAckHandler}. * @param connection the connection * @param subscribe the <code>SUBSCRIBE</code> frame * @param messages the acknowledge messages * @return the current {@link io.vertx.rxjava.ext.stomp.StompServerHandler} */ public io.vertx.rxjava.ext.stomp.StompServerHandler onAck(io.vertx.rxjava.ext.stomp.StompServerConnection connection, Frame subscribe, List<Frame> messages) { delegate.onAck(connection.getDelegate(), subscribe, messages); return this; }
/** * Gets the destination with the given name. * @param destination the destination * @return the {@link io.vertx.rxjava.ext.stomp.Destination}, <code>null</code> if not existing. */ public io.vertx.rxjava.ext.stomp.Destination getDestination(String destination) { io.vertx.rxjava.ext.stomp.Destination ret = io.vertx.rxjava.ext.stomp.Destination.newInstance(delegate.getDestination(destination)); return ret; }
/** * Creates an instance of {@link io.vertx.rxjava.ext.stomp.StompServerHandler} using the default (compliant) implementation. * @param vertx the vert.x instance to use * @return the created {@link io.vertx.rxjava.ext.stomp.StompServerHandler} */ public static io.vertx.rxjava.ext.stomp.StompServerHandler create(io.vertx.rxjava.core.Vertx vertx) { io.vertx.rxjava.ext.stomp.StompServerHandler ret = io.vertx.rxjava.ext.stomp.StompServerHandler.newInstance(io.vertx.ext.stomp.StompServerHandler.create(vertx.getDelegate())); return ret; }
/** * Gets a {@link io.vertx.rxjava.ext.stomp.Destination} object if existing, or create a new one. The creation is delegated to the * {@link io.vertx.rxjava.ext.stomp.DestinationFactory}. * @param destination the destination * @return the {@link io.vertx.rxjava.ext.stomp.Destination} instance, may have been created. */ public io.vertx.rxjava.ext.stomp.Destination getOrCreateDestination(String destination) { io.vertx.rxjava.ext.stomp.Destination ret = io.vertx.rxjava.ext.stomp.Destination.newInstance(delegate.getOrCreateDestination(destination)); return ret; }
/** * Configures the action to execute when a <code>CONNECT</code> frame is received. * @param handler the handler * @return the current {@link io.vertx.rxjava.ext.stomp.StompServerHandler} */ public io.vertx.rxjava.ext.stomp.StompServerHandler connectHandler(Handler<io.vertx.rxjava.ext.stomp.ServerFrame> handler) { delegate.connectHandler(new Handler<io.vertx.ext.stomp.ServerFrame>() { public void handle(io.vertx.ext.stomp.ServerFrame event) { handler.handle(io.vertx.rxjava.ext.stomp.ServerFrame.newInstance(event)); } }); return this; }
/** * @return the list of destination managed by the STOMP server. Don't forget the STOMP interprets destination as opaque Strings. */ public List<io.vertx.rxjava.ext.stomp.Destination> getDestinations() { List<io.vertx.rxjava.ext.stomp.Destination> ret = delegate.getDestinations().stream().map(elt -> io.vertx.rxjava.ext.stomp.Destination.newInstance(elt)).collect(java.util.stream.Collectors.toList()); return ret; }
/** * Something has happened, so handle it. * @param event the event to handle */ public void handle(io.vertx.rxjava.ext.stomp.ServerFrame event) { delegate.handle(event.getDelegate()); }
/** * Method called by single message (client-individual policy) or a set of message (client policy) are acknowledged. * Implementations must call the handler configured using {@link io.vertx.rxjava.ext.stomp.StompServerHandler#onAckHandler}. * @param connection the connection * @param subscribe the <code>SUBSCRIBE</code> frame * @param messages the acknowledge messages * @return the current {@link io.vertx.rxjava.ext.stomp.StompServerHandler} */ public io.vertx.rxjava.ext.stomp.StompServerHandler onAck(io.vertx.rxjava.ext.stomp.StompServerConnection connection, Frame subscribe, List<Frame> messages) { delegate.onAck(connection.getDelegate(), subscribe, messages); return this; }
/** * Gets the destination with the given name. * @param destination the destination * @return the {@link io.vertx.rxjava.ext.stomp.Destination}, <code>null</code> if not existing. */ public io.vertx.rxjava.ext.stomp.Destination getDestination(String destination) { io.vertx.rxjava.ext.stomp.Destination ret = io.vertx.rxjava.ext.stomp.Destination.newInstance(delegate.getDestination(destination)); return ret; }
/** * Creates an instance of {@link io.vertx.rxjava.ext.stomp.StompServerHandler} using the default (compliant) implementation. * @param vertx the vert.x instance to use * @return the created {@link io.vertx.rxjava.ext.stomp.StompServerHandler} */ public static io.vertx.rxjava.ext.stomp.StompServerHandler create(io.vertx.rxjava.core.Vertx vertx) { io.vertx.rxjava.ext.stomp.StompServerHandler ret = io.vertx.rxjava.ext.stomp.StompServerHandler.newInstance(io.vertx.ext.stomp.StompServerHandler.create(vertx.getDelegate())); return ret; }
/** * Gets a {@link io.vertx.rxjava.ext.stomp.Destination} object if existing, or create a new one. The creation is delegated to the * {@link io.vertx.rxjava.ext.stomp.DestinationFactory}. * @param destination the destination * @return the {@link io.vertx.rxjava.ext.stomp.Destination} instance, may have been created. */ public io.vertx.rxjava.ext.stomp.Destination getOrCreateDestination(String destination) { io.vertx.rxjava.ext.stomp.Destination ret = io.vertx.rxjava.ext.stomp.Destination.newInstance(delegate.getOrCreateDestination(destination)); return ret; }
/** * Configures the action to execute when a <code>CONNECT</code> frame is received. * @param handler the handler * @return the current {@link io.vertx.rxjava.ext.stomp.StompServerHandler} */ public io.vertx.rxjava.ext.stomp.StompServerHandler connectHandler(Handler<io.vertx.rxjava.ext.stomp.ServerFrame> handler) { delegate.connectHandler(new Handler<io.vertx.ext.stomp.ServerFrame>() { public void handle(io.vertx.ext.stomp.ServerFrame event) { handler.handle(io.vertx.rxjava.ext.stomp.ServerFrame.newInstance(event)); } }); return this; }