subscribe Optional
abstract suspend fun <T : Any> subscribeOptional(headers: StompSubscribeHeaders, clazz: KClass<T>): Flow<T?>
Content copied to clipboard
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 into instances of T or null, but the exact conversion is implementation-dependent. Message frames without a body MAY be skipped or result in an exception depending on the implementation, but they usually should be translated to null.
See the general StompSession documentation for more details about subscription flows and receipts.