Package org.inthewaves.kotlinsignald.subscription

Types

Link copied to clipboard
class ChannelMessageSubscriptionHandler(signaldClient: SignaldClient, coroutineScope: CoroutineScope, context: CoroutineContext, bufferCapacity: Int, onBufferOverflow: BufferOverflow, onUndeliveredElement: (ClientMessageWrapper) -> Unit?) : CoroutineMessageSubscriptionHandler

Creates a Channel-based message handler. Messages can be received by receiving elements from the messages. Unsubscription and closing of the socket is handled by calling close or cancelling the given coroutineScope.

Link copied to clipboard
abstract class CoroutineMessageSubscriptionHandler(signaldClient: SignaldClient, coroutineScope: CoroutineScope, context: CoroutineContext) : AutoCloseable

An abstract incoming message subscription handler that uses a coroutine to handle the event loop for messages.

Link copied to clipboard
class FlowMessageSubscriptionHandler(signaldClient: SignaldClient, coroutineScope: CoroutineScope, context: CoroutineContext, replay: Int, extraBufferCapacity: Int, onBufferOverflow: BufferOverflow) : CoroutineMessageSubscriptionHandler

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.

Functions

Link copied to clipboard
fun CoroutineScope.signalMessagesChannel(signaldClient: SignaldClient, context: CoroutineContext = EmptyCoroutineContext, bufferCapacity: Int = Channel.RENDEZVOUS, onBufferOverflow: BufferOverflow = BufferOverflow.SUSPEND, onUndeliveredElement: (ClientMessageWrapper) -> Unit? = null): ReceiveChannel<ClientMessageWrapper>

Launches a new coroutine that uses the signaldClient to create a new socket connection and using the socket to subscribe to incoming messages from signald. The incoming messages are sent through the returned ReceiveChannel.

Link copied to clipboard
fun CoroutineScope.signalMessagesSharedFlow(signaldClient: SignaldClient, context: CoroutineContext = EmptyCoroutineContext, replay: Int = DEFAULT_REPLAY, extraBufferCapacity: Int = DEFAULT_EXTRA_BUFFER_CAPACITY, onBufferOverflow: BufferOverflow = BufferOverflow.SUSPEND): SharedFlow<ClientMessageWrapper>

Launches a new coroutine that uses the IncomingMessageSubscription to handle incoming messages from signald. The incoming messages are emitted in the returned SharedFlow.