ConnectionHandlingStompSession

A {@link StompSession} that implements {@link hunt.stomp.tcp.TcpConnectionHandler TcpConnectionHandler} in order to send and receive messages.

<p>A ConnectionHandlingStompSession can be used with any TCP or WebSocket library that is adapted to the {@code TcpConnectionHandler} contract.

@author Rossen Stoyanchev @since 4.2

interface ConnectionHandlingStompSession : StompSession {}

Members

Functions

getSessionFuture
StompSession getSessionFuture()

Return a future that will complete when the session is ready for use.

Inherited Members

From StompSession

getSessionId
string getSessionId()

Return the id for the session.

isConnected
bool isConnected()

Whether the session is connected.

setAutoReceipt
void setAutoReceipt(bool enabled)

When enabled, a receipt header is automatically added to future {@code send} and {@code subscribe} operations on this session, which causes the server to return a RECEIPT. An application can then use the {@link StompSession.Receiptable Receiptable} returned from the operation to track the receipt. <p>A receipt header can also be added manually through the overloaded methods that accept {@code StompHeaders}.

send
Receiptable send(string destination, Object payload)

Send a message to the specified destination, converting the payload to a {@code byte[]} with the help of a {@link hunt.stomp.converter.MessageConverter MessageConverter}. @param destination the destination to send a message to @param payload the message payload @return a Receiptable for tracking receipts

send
Receiptable send(StompHeaders headers, Object payload)

An overloaded version of {@link #send(string, Object)} with full {@link StompHeaders} instead of just a destination. The headers must contain a destination and may also have other headers such as "content-type" or custom headers for the broker to propagate to subscribers, or broker-specific, non-standard headers.. @param headers the message headers @param payload the message payload @return a Receiptable for tracking receipts

subscribe
Subscription subscribe(string destination, StompFrameHandler handler)

Subscribe to the given destination by sending a SUBSCRIBE frame and handle received messages with the specified {@link StompFrameHandler}. @param destination the destination to subscribe to @param handler the handler for received messages @return a handle to use to unsubscribe and/or track receipts

subscribe
Subscription subscribe(StompHeaders headers, StompFrameHandler handler)

An overloaded version of {@link #subscribe(string, StompFrameHandler)} with full {@link StompHeaders} instead of just a destination. @param headers the headers for the subscribe message frame @param handler the handler for received messages @return a handle to use to unsubscribe and/or track receipts

acknowledge
Receiptable acknowledge(string messageId, bool consumed)

Send an acknowledgement whether a message was consumed or not resulting in an ACK or NACK frame respectively. <p><strong>Note:</strong> to use this when subscribing you must set the {@link StompHeaders#setAck(string) ack} header to "client" or "client-individual" in order ot use this. @param messageId the id of the message @param consumed whether the message was consumed or not @return a Receiptable for tracking receipts @since 4.3

acknowledge
Receiptable acknowledge(StompHeaders headers, bool consumed)

An overloaded version of {@link #acknowledge(string, )} with full {@link StompHeaders} instead of just a {@code messageId}. @param headers the headers for the ACK or NACK message frame @param consumed whether the message was consumed or not @return a Receiptable for tracking receipts @since 5.0.5

disconnect
void disconnect()

Disconnect the session by sending a DISCONNECT frame.

Meta