onMessage
A nullable property that can be set to a function (or lambda expression) to handle incoming message events. This function is invoked whenever a new message is received, providing a convenient way to process or react to messages.
Note that this property allows for the assignment of a singular behavior at a time, as any new assignment will override the previous one. For scenarios requiring multiple behaviors in response to message events, it is advisable to utilize EventEmitter.addListener.
To deactivate the current behavior, simply set this property to null.
Setting a Behavior Example:
onMessage = { pnMessageResult ->
println("Received message: ${pnMessageResult.message}")
}Content copied to clipboard
Removing a Behavior Example:
onMessage = nullContent copied to clipboard