fun MessagingService.runOnNextMessage(topic: String, sessionID: Long, executor: Executor? = null, callback: (Message) -> Unit): Unit
Registers a handler for the given topic and session ID that runs the given callback with the message and then removes itself. This is useful for one-shot handlers that arent supposed to stick around permanently. Note that this callback doesnt take the registration object, unlike the callback to MessagingService.addMessageHandler, as the handler is automatically deregistered before the callback runs.
topic
- identifier for the general subject of the message, for example "platform.network_map.fetch".
The topic can be the empty string to match all messages (session ID must be DEFAULT_SESSION_ID).sessionID
- identifier for the session the message is part of. For services listening before
a session is established, use DEFAULT_SESSION_ID.inline fun MessagingService.runOnNextMessage(topicSession: TopicSession, executor: Executor? = null, crossinline callback: (Message) -> Unit): Unit
Registers a handler for the given topic and session that runs the given callback with the message and then removes itself. This is useful for one-shot handlers that arent supposed to stick around permanently. Note that this callback doesnt take the registration object, unlike the callback to MessagingService.addMessageHandler.
topicSession
- identifier for the topic and session to listen for messages arriving on.