/** * Creates a {@link StompClient} using the default implementation. * * @param vertx the vert.x instance to use * @return the created {@link StompClient} */ static StompClient create(Vertx vertx) { return create(vertx, new StompClientOptions()); }
/** * 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()); }
static void handleReceipt(Frame frame, StompServerConnection connection) { String receipt = frame.getReceipt(); if (receipt != null) { connection.write(createReceiptFrame(receipt, Headers.create())); } }
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; } }
/** * 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); }
/** * Sends an acknowledgement for a specific message. It means that the message has been handled and processed by the * client. The <code>id</code> parameter is the message id received in the frame. * @param id the message id of the message to acknowledge * @return the current {@link io.vertx.rxjava.ext.stomp.StompClientConnection} */ public io.vertx.rxjava.ext.stomp.StompClientConnection ack(String id) { delegate.ack(id); return this; }
/** * 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; }
/** * @return the received frame */ public Frame frame() { Frame ret = delegate.frame(); return ret; }
/** * Closes the connection without sending the <code>DISCONNECT</code> frame. */ public void close() { delegate.close(); }
/** * Sends the given frame to the server. * @param frame the frame * @return the current {@link io.vertx.rxjava.ext.stomp.StompClientConnection} */ public io.vertx.rxjava.ext.stomp.StompClientConnection send(Frame frame) { delegate.send(frame); return this; }
/** * Un-subscribes from the given destination. This method only works if the subscription did not specifies a * subscription id (using the <code>id</code> header). * @param destination the destination * @return the current {@link io.vertx.rxjava.ext.stomp.StompClientConnection} */ public io.vertx.rxjava.ext.stomp.StompClientConnection unsubscribe(String destination) { delegate.unsubscribe(destination); return this; }
/** * Begins a transaction. * @param id the transaction id, must not be <code>null</code> * @param headers additional headers to send to the server. The <code>transaction</code> header is replaced by the value passed in the @{code id} parameter * @param receiptHandler the handler invoked when the <code>RECEIPT</code> frame associated with the transaction begin has been processed by the server. The handler receives the sent frame (<code>BEGIN</code>). * @return the current {@link io.vertx.rxjava.ext.stomp.StompClientConnection} */ public io.vertx.rxjava.ext.stomp.StompClientConnection beginTX(String id, Map<String, String> headers, Handler<Frame> receiptHandler) { delegate.beginTX(id, headers, receiptHandler); return this; }
/** * Commits a transaction. * @param id the transaction id, must not be <code>null</code> * @param headers additional headers to send to the server. The <code>transaction</code> header is replaced by the value passed in the @{code id} parameter * @return the current {@link io.vertx.rxjava.ext.stomp.StompClientConnection} */ public io.vertx.rxjava.ext.stomp.StompClientConnection commit(String id, Map<String, String> headers) { delegate.commit(id, headers); return this; }
/** * Aborts a transaction. * @param id the transaction id, must not be <code>null</code> * @param headers additional headers to send to the server. The <code>transaction</code> header is replaced by the value passed in the @{code id} parameter * @param receiptHandler the handler invoked when the <code>RECEIPT</code> frame associated with the transaction cancellation has been processed by the server. The handler receives the sent frame (<code>ABORT</code>). * @return the current {@link io.vertx.rxjava.ext.stomp.StompClientConnection} */ public io.vertx.rxjava.ext.stomp.StompClientConnection abort(String id, Map<String, String> headers, Handler<Frame> receiptHandler) { delegate.abort(id, headers, receiptHandler); return this; }
/** * Sends a non-acknowledgement for the given frame. It means that the frame has not been handled by the client. * The sent non-acknowledgement is part of the transaction identified by the given id. * @param id the message id of the message to acknowledge * @param txId the transaction id * @param receiptHandler the handler invoked when the <code>RECEIPT</code> frame associated with the non-acknowledgment has been processed by the server. The handler receives the sent frame (<code>NACK</code>). * @return the current {@link io.vertx.rxjava.ext.stomp.StompClientConnection} */ public io.vertx.rxjava.ext.stomp.StompClientConnection nack(String id, String txId, Handler<Frame> receiptHandler) { delegate.nack(id, txId, receiptHandler); 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; }
/** * @return the subscription frame */ public Frame subscription() { Frame ret = delegate.subscription(); return ret; }
/** * @return the server name. */ public String server() { String ret = delegate.server(); return ret; }
/** * Sends a `PING` frame to the client. A `PING` frame is a frame containing only <code>EOL</code>. */ public void ping() { delegate.ping(); }