Callback listeners

Observing the connection events Individually#

To monitor the chat connection status, you can achieve this by defining a ChatConnectionListener interface. You have the option to either implement this interface directly or create an anonymous class that adheres to the ChatConnectionListener interface. Subsequently, attach the listener to your ChatConnectionManager instance. This allows you to receive updates on the connection status, such as when the chat is connected, disconnected, or encounters an error.

tip

There can be used as multiple message listener at a time, if you set multiple times using the below method it will not replace the old listener.

Event Listener for Connection Success updates#

Mirrorfly.onConnected.listen((event){
});

Event Listener for Connection Disconnected Updates#

Mirrorfly.onDisconnected.listen((event){
});

Event Listener for Connection Failed Updates#

Mirrorfly.onConnectionFailed.listen((event){
});

Event Listener for logged out Updates#

When logout called then the following method will be triggered.

Mirrorfly.onLoggedOut.listen((event){
//You logged out of chat sdk update the UI
});

Observing the connection events Collectively#

Assign the listener to the appropriate class to receive event updates. Extend the class and implement the necessary event listeners collectively for streamlined integration you can register your own listener by using the below method.

tip

There can be only one message listener at a time, if you set multiple times using the below method it will replace the old listener always.

Mirrorfly.setConnectionEventListener(YourClass());
class YourClass extends ConnectionEventListeners{
@override
void onConnected() {
// TODO: implement onConnected
}
@override
void onConnectionFailed(String connectionError) {
// TODO: implement onConnectionFailed
}
@override
void onDisconnected() {
// TODO: implement onDisconnected
}
@override
void onLoggedOut() {
// TODO: implement onLoggedOut
}
}