setOnPresence

abstract fun setOnPresence(onPresenceHandler: OnPresenceHandler?)

Sets the handler for incoming presence events. This method allows the assignment of an OnPresenceHandler implementation or lambda expression to handle incoming presence events.

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 presence events, it is advisable to utilize EventEmitter.addListener.

Setting a Behavior Example:

`onPresenceHandler(pnPresenceEventResult -> System.out.println("Received: " + pnPresenceEventResult.getEvent()));
`
*

Removing a Behavior Example:

`onPresenceHandler(null);
`
*

Parameters

onPresenceHandler

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