FlowMessageSubscriptionHandler
Creates a SharedFlow-based message handler by creating a new socket connection and sending a subscribe request. Messages can be received by collecting from the messages flow. Unsubscription and closing of the socket is handled by calling close or cancelling the given coroutineScope. This is suitable for when multiple subscribers to incoming messages are desired.
Note that the messages flow is hot, meaning that it will be active regardless of whether there are any subscribers.
Parameters
The Signal instance. Must be associated with an account registered with signald.
The CoroutineScope to use for the message subscription coroutine. This is used to cancel the handler.
The number of values replayed to new subscribers (cannot be negative, defaults to zero).
Size of the buffer for emissions to the messages shared flow, allowing slow subscribers to get values from the buffer without suspending emitters. The buffer space determines how much slow subscribers can lag from the fast ones. (optional, cannot be negative, defaults to zero). This option should be used with care; setting a higher buffer means that the client will take messages from signald that will be buffered locally, but if the client crashes and never handles those messages, signald will not resend those messages.
configures an emit action on buffer overflow. Optional, defaults to suspending attempts to emit a value. Values other than BufferOverflow.SUSPEND are supported only when replay > 0
or extraBufferCapacity > 0
. Buffer overflow can happen only when there is at least one subscriber that is not ready to accept the new value. In the absence of subscribers only the most recent replay values are stored and the buffer overflow behavior is never triggered and has no effect.
Throws
if subscription fails (e.g., creating the persistent socket fails)
Constructors
Functions
Properties
A hot SharedFlow of incoming messages. As ClientMessageWrapper is a sealed type, using a when
statement on the message will be exhaustive.