/ SDKs / Unreal
SDKs
Chat SDKs Unreal v3
Chat SDKs Unreal
Chat SDKs
Unreal
Version 3

Add and remove a user event handler

Copy link

To receive information about events related to users connected to the Sendbird server, you need to add a user event handler with its unique user-defined ID by calling the SBDMain::AddUserEventHandler().

The following code shows a full set of supported event callbacks with their parameters and how to add a user event handler to the unique SendBird instance.

class MyUserEventHandler : public SBDUserEventHandler {
    void TotalUnreadMessageCountChanged(int total_count, std::map<std::wstring, int> total_count_by_custom_type) {
        // A user has read messages in the joined group channels and there is an update on the total number of the user's unread messages.
    }
};

SBDMain::AddUserEventHandler(UNIQUE_HANDLER_ID, new MyUserEventHandler());

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

// You can remove a specific user event handler. 
SBDMain::RemoveUserEventHandler(UNIQUE_HANDLER_ID);

// You can remove all registered user event handlers. 
SBDMain::RemoveAllUserEventHandlers();