/** * Writes the given frame to the socket. * @param frame the frame, must not be <code>null</code>. * @return the current {@link io.vertx.rxjava.ext.stomp.StompServerConnection} */ public io.vertx.rxjava.ext.stomp.StompServerConnection write(Frame frame) { delegate.write(frame); return this; }
/** * Closes the connection with the client. */ public void close() { delegate.close(); }
/** * Configures the heartbeat. * @param ping ping time * @param pong pong time * @param pingHandler the ping handler */ public void configureHeartbeat(long ping, long pong, Handler<io.vertx.rxjava.ext.stomp.StompServerConnection> pingHandler) { delegate.configureHeartbeat(ping, pong, new Handler<io.vertx.ext.stomp.StompServerConnection>() { public void handle(io.vertx.ext.stomp.StompServerConnection event) { pingHandler.handle(io.vertx.rxjava.ext.stomp.StompServerConnection.newInstance(event)); } }); }
private void authenticate(Frame frame, StompServerConnection connection, Handler<AsyncResult<Void>> remainingActions) { if (connection.server().options().isSecured()) { String login = frame.getHeader(Frame.LOGIN); String passcode = frame.getHeader(Frame.PASSCODE); connection.handler().onAuthenticationRequest(connection, login, passcode, ar -> { if (ar.result()) { remainingActions.handle(Future.succeededFuture()); } else { connection.write(Frames.createErrorFrame( "Authentication failed", Headers.create( Frame.VERSION, getSupportedVersionsHeaderLine(connection), Frame.CONTENT_TYPE, "text/plain"), "The connection frame does not contain valid credentials.") ); connection.close(); } }); } else { remainingActions.handle(Future.succeededFuture()); } }
if (res.failed()) { Throwable cause = res.cause(); connection.write(Frames.createErrorFrame("Message dispatch error", Headers.create(Frame.DESTINATION, address, "reply-address", replyAddress), cause.getMessage())).close(); } else { if (subscription.isPresent()) { Frame stompFrame = transform(res.result(), subscription.get()); subscription.get().connection.write(stompFrame); connection.write(Frames.createErrorFrame("Access denied", Headers.create(Frame.DESTINATION, address), "Access denied to " + address)).close(); return null;
connection.write( Frames.createErrorFrame( "Invalid unsubscribe", Headers.create(frame.getHeaders()), "The 'id' header must be set")); connection.close(); return; List<Destination> destinations = connection.handler().getDestinations(); boolean handled = false; for (Destination destination : destinations) { connection.write(Frames.createErrorFrame( "Invalid unsubscribe", Headers.create(frame.getHeaders()), "No subscription associated with the given 'id'")); connection.close(); return;
sf.connection().write(Frames.createErrorFrame( "Incompatible versions", Headers.create( "Supported protocol versions are " + getSupportedVersionsHeaderLine(sf.connection())) ); sf.connection().close(); return; sf.connection().write(new Frame(Frame.Command.CONNECTED, Headers.create( Frame.VERSION, version, Frame.SERVER, Server.SERVER_NAME, Frame.SESSION, sf.connection().session(), Frame.HEARTBEAT, Frame.Heartbeat.create(sf.connection().server().options().getHeartbeat()).toString()), null)); });
private void handleConnect(Frame frame, StompServerConnection connection) { Handler<ServerFrame> handler; Handler<StompServerConnection> pingH; synchronized (this) { handler = connectHandler; pingH = pingHandler; } // Compute heartbeat, and register pinger and ponger // Stomp server acts as a client to call the computePingPeriod & computePongPeriod method long ping = Frame.Heartbeat.computePingPeriod( Frame.Heartbeat.create(connection.server().options().getHeartbeat()), Frame.Heartbeat.parse(frame.getHeader(Frame.HEARTBEAT))); long pong = Frame.Heartbeat.computePongPeriod( Frame.Heartbeat.create(connection.server().options().getHeartbeat()), Frame.Heartbeat.parse(frame.getHeader(Frame.HEARTBEAT))); connection.configureHeartbeat(ping, pong, pingH); // Then, handle the frame. if (handler != null) { handler.handle(new ServerFrameImpl(frame, connection)); } }
/** * @return the STOMP server serving this connection. */ public io.vertx.rxjava.ext.stomp.StompServer server() { io.vertx.rxjava.ext.stomp.StompServer ret = io.vertx.rxjava.ext.stomp.StompServer.newInstance(delegate.server()); return ret; }
/** * Notifies the connection about server activity (the server has sent a frame). This method is used to handle the * heartbeat. */ public void onServerActivity() { delegate.onServerActivity(); }
/** * @return the STOMP session id computed when the client has established the connection to the server */ public String session() { String ret = delegate.session(); return ret; }
/** * @return the STOMP server handler dealing with this connection */ public io.vertx.rxjava.ext.stomp.StompServerHandler handler() { io.vertx.rxjava.ext.stomp.StompServerHandler ret = io.vertx.rxjava.ext.stomp.StompServerHandler.newInstance(delegate.handler()); return ret; }
connection.write(Frames.createErrorFrame( "Invalid subscription", Headers.create( frame.getHeaders()), "The 'destination' and 'id' headers must be set")); connection.close(); return; for (Destination dest : connection.handler().getDestinations()) { List<String> ids = dest.getSubscriptions(connection); count += ids.size(); if (ids.contains(id)) { connection.write(Frames.createErrorFrame( "Invalid subscription", Headers.create(frame.getHeaders()), "'id'" + " already used by this connection.")); connection.close(); return; if (count + 1 > connection.server().options().getMaxSubscriptionsByClient()) { connection.write(Frames.createErrorFrame( "Invalid subscription", Headers.create(frame.getHeaders()), "Too many subscriptions")); connection.close(); return; final Destination dest = connection.handler().getOrCreateDestination(destination); if (dest != null) { if (dest.subscribe(connection, frame) == null) {
@Override public void handle(ServerFrame serverFrame) { Frame frame = serverFrame.frame(); StompServerConnection connection = serverFrame.connection(); String txId = frame.getHeader(Frame.TRANSACTION); if (txId == null) { Frame error = Frames.createErrorFrame("Missing transaction id", Headers.create(), "BEGIN frames " + "must contain the 'transaction' header."); connection.write(error).close(); return; } if (!Transactions.instance().registerTransaction(connection, txId)) { Frame error = Frames.createErrorFrame("Already existing transaction", Headers.create(Frame.TRANSACTION, txId), "A transaction using the same id is still active."); connection.write(error).close(); return; } Frames.handleReceipt(frame, connection); } }
String id = frame.getId(); if (id == null) { connection.write(Frames.createErrorFrame( "Id header missing", Headers.create(frame.getHeaders()), "Invalid ACK frame - the " + "'id' must be set")); connection.close(); return; Headers.create(Frame.ID, id, Frame.TRANSACTION, txId), "Message delivery failed - unknown transaction id in ACK message"); connection.write(errorFrame); connection.close(); return; } else { "may have been reached"); Transactions.instance().unregisterTransactionsFromConnection(connection); connection.write(errorFrame); connection.close(); return; final List<Destination> destinations = connection.handler().getDestinations(); for (Destination destination : destinations) { if (destination.ack(connection, frame)) {
/** * @return the STOMP server serving this connection. */ public io.vertx.rxjava.ext.stomp.StompServer server() { io.vertx.rxjava.ext.stomp.StompServer ret = io.vertx.rxjava.ext.stomp.StompServer.newInstance(delegate.server()); return ret; }
/** * Notifies the connection about server activity (the server has sent a frame). This method is used to handle the * heartbeat. */ public void onServerActivity() { delegate.onServerActivity(); }
/** * @return the STOMP session id computed when the client has established the connection to the server */ public String session() { String ret = delegate.session(); return ret; }
/** * @return the STOMP server handler dealing with this connection */ public io.vertx.rxjava.ext.stomp.StompServerHandler handler() { io.vertx.rxjava.ext.stomp.StompServerHandler ret = io.vertx.rxjava.ext.stomp.StompServerHandler.newInstance(delegate.handler()); return ret; }