Chat / Flutter
Chat Flutter v3
Chat Flutter
Chat
Flutter
Version 3
Home
/
Chat
/
Flutter
/
Event handler

Add or remove a connection event handler

To detect changes in the connection status of a client app, add a connection event handler with its unique user-defined ID by calling addConnectionEventHandler().

If you want to stay informed of changes related to the Sendbird server connection status and notify client apps of these changes, define and register multiple connection event handlers to each view controller.


Connection event types

List of connection events

MethodInvoked whenNotified devices

onReconnectionStarted()

The Chat SDK has started reconnecting to the Sendbird server.

The device where connect() was automatically called by the Chat SDK, or manually by the client app.

onReconnectionSucceeded()

The Chat SDK has succeeded in reconnecting to the Sendbird server.

The device that successfully reconnected to the server.

onReconnectionFailed()

The Chat SDK has failed to reconnect to the Sendbird server.

The device that failed to reconnect to the server.

onReconnectionCanceled()

The Chat SDK has been canceled to reconnect to the Sendbird server.

The device that canceled to reconnect to the server.


Add a connection event handler

The following code shows a full set of supported event callbacks and how to add a connection event handler to the unique SendbirdSdk instance.

class MyClass with ConnectionEventHandler {
    // Add this class via sendbird.addConnectionEventHandler(UNIQUE_HANDLER_ID, this).
    // Or remove it with sendbird.removeConnectionEventHandler(UNIQUE_HANDLER_ID) when it's no longer needed.

    @override
    void onReconnectionStarted() {

    }
}

Remove a connection event handler

The following code shows how to remove the connection event handler.

sendbird.removeConnectionEventHandler(UNIQUE_HANDLER_ID);