TypedStompSession

A StompSession with additional methods to serialize/deserialize message bodies based on a KClass.

Functions

Link copied to clipboard
abstract suspend fun abort(transactionId: String)

Sends an ABORT frame with the given transactionId.

Link copied to clipboard
abstract suspend fun ack(ackId: String, transactionId: String? = null)

Sends an ACK frame with the given ackId.

Link copied to clipboard
abstract suspend fun begin(transactionId: String)

Sends a BEGIN frame with the given transactionId.

Link copied to clipboard
abstract suspend fun commit(transactionId: String)

Sends a COMMIT frame with the given transactionId.

Link copied to clipboard
abstract suspend fun <T> convertAndSend(headers: StompSendHeaders, body: T, bodyType: KTypeRef<T>): StompReceipt?

Sends a SEND frame to the server with the given headers and the given body, converted appropriately based on bodyType.

Link copied to clipboard
inline suspend fun <T> TypedStompSession.convertAndSend(destination: String, body: T): StompReceipt?

Sends a SEND frame to the server at the given destination with the given body, converted appropriately.

inline suspend fun <T> TypedStompSession.convertAndSend(headers: StompSendHeaders, body: T): StompReceipt?

Sends a SEND frame to the server with the given headers and body, converted appropriately.

Link copied to clipboard
abstract suspend fun disconnect()

If graceful disconnect is enabled (which is the default), sends a DISCONNECT frame to close the session, waits for the relevant RECEIPT frame, and then closes the connection. Otherwise, force-closes the connection.

Link copied to clipboard
abstract suspend fun nack(ackId: String, transactionId: String? = null)

Sends a NACK frame with the given ackId.

Link copied to clipboard
abstract suspend fun send(headers: StompSendHeaders, body: FrameBody?): StompReceipt?

Sends a SEND frame to the server with the given headers and the given body.

Link copied to clipboard
suspend fun StompSession.sendBinary(destination: String, body: ByteArray?): StompReceipt?

Sends a SEND frame to the server at the given destination with the given binary body.

Link copied to clipboard
suspend fun StompSession.sendEmptyMsg(destination: String): StompReceipt?

Sends a SEND frame to the server at the given destination without body.

Link copied to clipboard
suspend fun StompSession.sendText(destination: String, body: String?): StompReceipt?

Sends a SEND frame to the server at the given destination with the given textual body.

Link copied to clipboard
abstract suspend fun subscribe(headers: StompSubscribeHeaders): Flow<StompFrame.Message>

Subscribes and returns a Flow of MESSAGE frames that unsubscribes automatically when the collector is done or cancelled. The returned flow can be collected only once.

abstract suspend fun <T> subscribe(headers: StompSubscribeHeaders, type: KTypeRef<T>): Flow<T>

Subscribes and returns a Flow of messages of type T that unsubscribes automatically when the collector is done or cancelled. The returned flow can be collected only once.

Link copied to clipboard
suspend fun StompSession.subscribe(destination: String): Flow<StompFrame.Message>

Subscribes and returns a Flow of MESSAGE frames that unsubscribes automatically when the collector is done or cancelled. The returned flow can be collected only once.

inline suspend fun <T> TypedStompSession.subscribe(destination: String): Flow<T>

Subscribes to the given destination and returns a Flow of messages of type T that unsubscribes automatically when the collector is done or cancelled. The returned flow can be collected only once.

Link copied to clipboard
suspend fun StompSession.subscribeBinary(destination: String): Flow<ByteArray>

Subscribes and returns a Flow of binary message bodies that unsubscribes automatically when the collector is done or cancelled. The returned flow can be collected only once.

Link copied to clipboard
suspend fun StompSession.subscribeText(destination: String): Flow<String>

Subscribes and returns a Flow of text message bodies that unsubscribes automatically when the collector is done or cancelled. The returned flow can be collected only once.

Link copied to clipboard

Wraps this StompSession to add methods that can convert message bodies using the provided converter.

Link copied to clipboard
suspend fun <T> StompSession.withTransaction(block: suspend StompSession.(transactionId: String) -> T): T

Executes the given block as part of a transaction.