subscribe

suspend fun <T : Any> StompSessionWithKxSerialization.subscribe(destination: String, deserializer: DeserializationStrategy<T>): Flow<T>(source)

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.

The received MESSAGE frames are converted to instances of T using the provided Kotlinx Serialization's deserializer. Message frames without a body are not allowed and result in an exception in the flow's collector.

See the general StompSession documentation for more details about subscription flows and receipts.


inline suspend fun <T : Any> StompSessionWithKxSerialization.subscribe(destination: String): Flow<T>(source)

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.

The received MESSAGE frames are converted to instances of T using a deserializer inferred from the class of T. This has limited support in JavaScript and may break on generic types. Message frames without a body are not allowed and result in an exception in the flow's collector.

See the general StompSession documentation for more details about subscription flows and receipts.