setOnMessage

abstract fun setOnMessage(onMessageHandler: OnMessageHandler?)

Sets the handler for incoming message events. This method allows the assignment of an OnMessageHandler implementation or lambda expression to handle incoming messages.

To deactivate the current behavior, simply set this property to null.

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.

Setting a Behavior Example:

`setOnMessage(pnMessageResult -> System.out.println("Received: " + pnMessageResult.getMessage()));
`
*

Removing a Behavior Example:

`setOnMessage(null);
`
*

Parameters

onMessageHandler

An implementation of OnMessageHandler or a lambda expression to handle incoming messages. It can be null to remove the current handler.