/** * @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; }
/** * @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; }
private String getSupportedVersionsHeaderLine(StompServerConnection connection) { StringBuilder builder = new StringBuilder(); connection.server().options().getSupportedVersions().stream().forEach( v -> builder.append(builder.length() == 0 ? v : FrameParser.COMMA + v)); return builder.toString(); }
/** * Adds a frame to the transaction. As stated in the STOMP specification, only {@code SEND, ACK and NACK} frames * can be in transactions. * * @param frame the frame to add * @return {@code true} if the frame was added to the transaction, {@code false otherwise}. Main failure reason is the number of * frames stored in the transaction that have exceed the number of allowed frames in transaction. */ public synchronized boolean addFrameToTransaction(Frame frame) { return frames.size() < connection.server().options().getMaxFrameInTransaction() && frames.add(frame); }
private String negotiate(List<String> accepted, StompServerConnection connection) { List<String> supported = connection.server().options().getSupportedVersions(); for (String v : supported) { if (accepted.contains(v)) { return v; } } return null; } }
private void replay(StompServerConnection connection, List<Frame> frames) { // To avoid blocking the event loop for too long, we replay the transaction chunk by chunk. Iterator<Frame> iterator = frames.iterator(); while (iterator.hasNext()) { List<Frame> chunk = new ArrayList<>(); while (iterator.hasNext() && chunk.size() < connection.server().options().getTransactionChunkSize()) { chunk.add(iterator.next()); } connection.server().vertx().runOnContext(v -> replayChunk(connection, chunk)); } }
final StompServer server = connection.server(); if (!server.options().isSecured()) { if (auth != null) {
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()); } }
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)); } }
Frame.SERVER, Server.SERVER_NAME, Frame.SESSION, sf.connection().session(), Frame.HEARTBEAT, Frame.Heartbeat.create(sf.connection().server().options().getHeartbeat()).toString()), null)); });
return; if (count + 1 > connection.server().options().getMaxSubscriptionsByClient()) { connection.write(Frames.createErrorFrame( "Invalid subscription",
if (dest == null && sf.connection().server().options().isSendErrorOnNoSubscriptions()) { Frame errorFrame = Frames.createErrorFrame( "No subscriptions",