Sendbird Chat SDK for Unity provides two types of event handlers: channel handler and connection handler. Through the channel handler, Sendbird server notifies client apps of events that happen on the channels and users of your app. In cases where the client app gets disconnected from the server and tries to reconnect at the SDK level, the server notifies the client app through the connection handler.
Using the event callbacks provided by two types of handlers, you can write the event-related processing code you want to execute. For example, the
ChannelHandler.onMessageReceived() is called when a message has been received in a channel. This callback receives
BaseMessage objects which contain new information on the channel and message as parameters.
The Sendbird SDKs interact with our server through persistent
WebSocket connections and multi-thread processing, and receives callbacks of asynchronous events which happen on the channels, users, and reconnect process of client apps in real-time through the handlers. This allows you to track the events and implement your own chat features associated with them.
To receive and retrieve information about certain events happening in the channels from Sendbird server, you need to register a channel handler with its unique user-defined ID by calling the
SendBirdClient.AddChannelHandler(). If you want to keep informed of changes related to the channels and notify other users' client apps of those changes, define and register multiple channel handlers to each activity instance.
OnChannelChanged() method is called whenever a one of the following channel properties have been changed:
- Push preference
- Last message (except in cases where the message is a silent Admin message)
- Unread message count
- Name, cover image, data, custom type
- Operators (only applicable to open channels)
- Distinct property (only applicable to group channels)
Where the activity isn't valid anymore, remove the channel handler.
To detect changes in the connection status of a client app, you need to register a connection handler with its unique user-defined ID by calling the
SendBirdClient.AddConnectionHandler(). If you want to keep informed of changes related to the Sendbird server connection, define and register multiple connection handlers to each activity instance.
Where the activity isn't valid anymore, remove the connection handler.