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

Add and remove a channel handler

Copy link

To receive and retrieve information about certain events happening in the channels from the Sendbird server, you need to register a channel handler with its unique user-defined ID by calling the SBDMain::AddConnectionHandler().

class MyChannelHandler : public SBDChannelHandler {
    void MessageReceived(SBDBaseChannel* channel, SBDBaseMessage* message) {
        // When a message is received.
    }

    void MessageUpdated(SBDBaseChannel* channel, SBDBaseMessage* message) {
        // When a message is updated.
    }

    void ReadReceiptUpdated(SBDGroupChannel* channel) {
        // When read receipts updated.
    }

    void InvitationReceived(SBDGroupChannel* channel, const std::vector<SBDUser>& invitees, SBDUser& inviter) {
        // When users are invited by inviter.
    }

    void InvitationDeclined(SBDGroupChannel* channel, SBDUser& invitee, SBDUser& inviter) {
        // When user declined the invitation.
    }

    void UserJoined(SBDGroupChannel* channel, SBDUser& user) {
        // When new member joined to the group channel.
    }

    void UserLeft(SBDGroupChannel* channel, SBDUser& user) {
        // When current member left from the group channel.
    }

    void UserEntered(SBDOpenChannel* channel, SBDUser& user) {
        // When a user enter an open channel.
    }

    void UserExited(SBDOpenChannel* channel, SBDUser& user) {
        // When a user exit an open channel.
    }

    void UserMuted(SBDOpenChannel* channel, SBDUser& user) {
        // When a user was muted in the open channel.
    }

    void UserUnmuted(SBDOpenChannel* channel, SBDUser& user) {
        // When a user was unmuted in the open channel.
    }

    void UserBanned(SBDOpenChannel* channel, SBDUser& user) {
        // When a user was banned in the open channel.
    }

    void UserUnbanned(SBDOpenChannel* channel, SBDUser& user) {
        // When a user was unbanned in the open channel.
    }

    void ChannelFrozen(SBDOpenChannel* channel) {
        // When an open channel was frozen.
    }

    void ChannelUnfrozen(SBDOpenChannel* channel) {
        // When an open channel was unfrozen.
    }

    void ChannelChanged(SBDBaseChannel* channel) {
        // When an open channel was changed.
    }

    void ChannelDeleted(const std::wstring& channel_url, SBDChannelType channel_type) {
        // When an open channel was deleted.
    }

    void MessageDeleted(SBDBaseChannel* channel, uint64_t message_id) {
        // When a message was removed in the channel.
    }

    void ChannelMetaDataCreated(SBDBaseChannel* channel, const std::map<std::wstring, std::wstring>& created_meta_data) {
        // When meta data was created in the channel.
    }

    void ChannelMetaDataUpdated(SBDBaseChannel* channel, const std::map<std::wstring, std::wstring>& updated_meta_data) {
        // When meta data was updated in the channel.
    }

    void ChannelMetaDataDeleted(SBDBaseChannel* channel, const std::vector<std::wstring>& deleted_meta_data) {
        // When meta data was deleted in the channel.
    }

    void ChannelMetaCountersCreated(SBDBaseChannel* channel, const std::map<std::wstring, int64_t>& created_meta_counters) {
        // When meta counters were created in the channel.
    }

    void ChannelMetaCountersUpdated(SBDBaseChannel* channel, const std::map<std::wstring, int64_t>& updated_meta_counters) {
        // When meta counters were updated in the channel.
    }

    void ChannelMetaCountersDeleted(SBDBaseChannel* channel, const std::vector<std::wstring>& deleted_meta_counters) {
        // When meta counters were deleted in the channel.
    }

    void MentionReceived(SBDBaseChannel* channel, SBDBaseMessage* message) {
        // When a mentioned user is received.
    }

    void ChannelWasHidden(SBDGroupChannel* channel) {
        // When the channel was hidden on the other device or by Platform API.
    }

    void OperatorUpdated(SBDBaseChannel* channel) {
        // When operators change in channel.
    }
};

SBDMain::AddChannelHandler(UNIQUE_HANDLER_ID, new MyChannelHandler());

The ChannelChanged() 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.

// You can remove a specific channel handler. 
SBDMain::RemoveChannelHandler(UNIQUE_HANDLER_ID);

// You can remove all registered channel handlers. 
SBDMain::RemoveAllChannelHandlers();