Register auth callbacks with XXMessengerClient
This MR allows registering auth callbacks with Messenger
from XXMessengerClient
library.
Callbacks can be registered at any time, but ideally should be registered before calling messenger.connect()
to make sure all callbacks are handled. More than one AuthCallbacks
can be registered, and all will receive callbacks, unless Cancellable
object returned from registerAuthCallbacks
is canceled (by calling cancel()
on it, or when dealocated).
// first, register callbacks:
var cancellable: Cancellable? = messenger.registerAuthCallbacks(
AuthCallbacks(handle: { callback in
// implement auth callbacks handling
})
)
// later, connect (which creates E2E and starts receiving callbacks):
messenger.connect()
// if registered callbacks are no longer needed:
cancellable?.cancel() // or: cancellable = nil