signalMessagesSharedFlow
Launches a new coroutine that uses the IncomingMessageSubscription to handle incoming messages from signald. The incoming messages are emitted in the returned SharedFlow.
The coroutine context is inherited from a CoroutineScope. Additional context elements can be specified with the context parameter.
Cancellation of the scope will unsubscribe from incoming messages and close the socket.
See also
Parameters
The Signal instance. Must be associated with an account registered with signald.
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)