public FrameParser() { this(new StompServerOptions()); }
public static void toJson(StompServerOptions obj, java.util.Map<String, Object> json) { if (obj.getHeartbeat() != null) { json.put("heartbeat", obj.getHeartbeat()); } json.put("maxBodyLength", obj.getMaxBodyLength()); json.put("maxFrameInTransaction", obj.getMaxFrameInTransaction()); json.put("maxHeaderLength", obj.getMaxHeaderLength()); json.put("maxHeaders", obj.getMaxHeaders()); json.put("maxSubscriptionsByClient", obj.getMaxSubscriptionsByClient()); json.put("secured", obj.isSecured()); json.put("sendErrorOnNoSubscriptions", obj.isSendErrorOnNoSubscriptions()); if (obj.getSupportedVersions() != null) { JsonArray array = new JsonArray(); obj.getSupportedVersions().forEach(item -> array.add(item)); json.put("supportedVersions", array); } json.put("timeFactor", obj.getTimeFactor()); json.put("trailingLine", obj.isTrailingLine()); json.put("transactionChunkSize", obj.getTransactionChunkSize()); json.put("websocketBridge", obj.isWebsocketBridge()); if (obj.getWebsocketPath() != null) { json.put("websocketPath", obj.getWebsocketPath()); } } }
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(); }
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)); } }
private boolean hasExceededBodySize() { return bodyLength >= options.getMaxBodyLength(); }
private boolean hasExceededHeaderLength(String header, String value) { return value.length() > options.getMaxHeaderLength() || header.length() > options.getMaxHeaderLength(); }
private boolean hasExceededNumberOfHeaders() { return headers.size() + 1 > options.getMaxHeaders(); }
/** * 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); }
return; if (count + 1 > connection.server().options().getMaxSubscriptionsByClient()) { connection.write(Frames.createErrorFrame( "Invalid subscription",
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; } }
Frame.SERVER, Server.SERVER_NAME, Frame.SESSION, sf.connection().session(), Frame.HEARTBEAT, Frame.Heartbeat.create(sf.connection().server().options().getHeartbeat()).toString()), null)); });
/** * Creates a {@link StompServer} based on the default Stomp Server implementation. * * @param vertx the vert.x instance to use * @param netServer the Net server used by the STOMP server * @return the created {@link StompServer} */ static StompServer create(Vertx vertx, NetServer netServer) { return new StompServerImpl(vertx, netServer, new StompServerOptions()); }
/** * Creates a {@link StompServer} based on the default Stomp Server implementation, and use the default options. * * @param vertx the vert.x instance to use * @return the created {@link StompServer} */ static StompServer create(Vertx vertx) { return create(vertx, new StompServerOptions()); }
public static io.vertx.ext.stomp.StompServer create(io.vertx.ext.stomp.StompServer j_receiver, io.vertx.core.Vertx vertx, java.util.Map<String, Object> options) { return io.vertx.core.impl.ConversionHelper.fromObject(io.vertx.ext.stomp.StompServer.create(vertx, options != null ? new io.vertx.ext.stomp.StompServerOptions(io.vertx.core.impl.ConversionHelper.toJsonObject(options)) : null)); } public static io.vertx.ext.stomp.StompServer create(io.vertx.ext.stomp.StompServer j_receiver, io.vertx.core.Vertx vertx, io.vertx.core.net.NetServer net, java.util.Map<String, Object> options) {
public static io.vertx.ext.stomp.StompServer create(io.vertx.ext.stomp.StompServer j_receiver, io.vertx.core.Vertx vertx, io.vertx.core.net.NetServer net, java.util.Map<String, Object> options) { return io.vertx.core.impl.ConversionHelper.fromObject(io.vertx.ext.stomp.StompServer.create(vertx, net, options != null ? new io.vertx.ext.stomp.StompServerOptions(io.vertx.core.impl.ConversionHelper.toJsonObject(options)) : null)); } }