Skip to content

Event management

The Chat feature sends the following four types of events to the app client.

  • Connection Event
  • Channel Event
  • User Event
  • Custom Data Event

You can receive events by registering an event listener with a custom key.

Connection event

The connection event is related to the Hive Chat socket server connection.

Connection event types

Event Name Occurrence Time Description
OnConnected When connection is successful [Deprecated] Occurs when the connection is successful.
OnConnectStarted When connection starts Occurs when connection starts.
OnConnectCompleted When connection completes Occurs after a connection attempt. Returns the success status as a result.
OnDisconnected When connection fails Occurs when the connection fails.
OnReconnectStarted When reconnection starts [Deprecated] Occurs when reconnection starts.
OnReconnected When reconnection is successful [Deprecated] Occurs after a reconnection attempt. If the reconnection request is successful within 10 minutes after the chat socket server is disconnected, it automatically attempts to join the previously participated channels, then returns the list of successfully joined channels and the list of failed channels as a result.
using hive;

ConnectionHandler connectionHandler = new ConnectionHandler
{
    OnConnectStarted() => 
    {
        // on connect started
    },
    OnConnectCompleted() = (ResultAPI result) =>
    {
        // on connect completed
    },
    OnDisconnected = () =>
    {
        // on disconnected
    }
};
Chat.addConnectionHandler("UNIQUE_KEY", connectionHandler); // add connection handler
Chat.removeConnectionHandler("UNIQUE_KEY"); // remove connection handler
#include "HiveChat.h"

class ConnectionListener : public FHiveConnectionListener {
public:
    UChatTestView* Owner;
    ConnectionListener(UChatTestView* InOwner) : Owner(InOwner) {}

    virtual void onConnectStarted() override {
        // on connect started
    }

    virtual void onConnectCompleted(const FHiveResultAPI& Result) override {
        // on connect completed
    }

    virtual void onDisconnected() override {
        // on disconnected
    }

};

FHiveChat::AddConnectionListener("UNIQUE_KEY", new ConnectionListener(this)); // add connection listener
FHiveChat::RemoveConnectionListener("UNIQUE_KEY"); // remove connection listener
#include <HIVE_SDK_Plugin/HIVE_CPP.h>
using namespace hive;

class ConnectionListenerImpl : public ConnectionListener {
    void onConnectStarted() override {
        // on connect started
    }

    void onConnectCompleted(ResultAPI const & result) override {
        // on connect completed
    }

    void onDisconnected() override {
        // on disconnected
    }

};

Chat::addConnectionListener("UNIQUE_KEY", new ConnectionListenerImpl()); // add connection listener
Chat::removeConnectionListener("UNIQUE_KEY"); // remove connection listener
import com.hive.Chat;

// add connection listener
Chat.addConnectionListener("UNIQUE_KEY", object : ConnectionListener{
    override fun onConnectStarted() {
        // on connect started
    }

    override fun onConnectCompleted(result: ResultAPI) {
        // on connect completed
    }

    override fun onDisconnected() {
        // on disconnected
    }

})

// remove connection listener
Chat.removeConnectionListener("UNIQUE_KEY"); 
import com.hive.Chat;

// add connection listener
Chat.addConnectionListener("UNIQUE_KEY", new Chat.ConnectionListener() {
    @Override
    public void onConnectStarted() {
        // on connect started
    }

    @Override
    public void onConnectCompleted(@NonNull ResultAPI result) {
        // on connect completed
    }

    @Override
    public void onDisconnected() {
        // on disconnected
    }

});

// remove connection listener
Chat.removeConnectionListener("UNIQUE_KEY"); 
import HIVEService

class ChatConnectionListener: HiveChatConnectionDelegate {
    func onConnectStarted() {
        // on connect started
    }

    func onConnectCompleted(result: ResultAPI) {
        // on connect completed
    }

    func onDisconnected() {
        // on disconnected
    }

}

ChatInterface.addConnectionListener(uniqueKey: "UNIQUE_KEY", listener: ChatConnectionListener()) // add connection listener
ChatInterface.removeConnectionListener(uniqueKey: "UNIQUE_KEY") // remove connection listener
#import "HIVEService.h"

@interface ChatConnectionListener : NSObject <HiveChatConnectionDelegate>
@end

@implementation ChatConnectionListener

- (void)onConnectStarted {
    // on connect Started
}

- (void)onConnectCompletedWithResult:(HIVEResultAPI *)result {
    // on connect completed
}

- (void)onDisconnected {
    // on disconnected
}


@end

[HiveChat addConnectionListenerWithUniqueKey:@"UNIQUE_KEY" listener:[[ChatConnectionListener alloc] init]]; // add connection listener
[HiveChat removeConnectionListenerWithUniqueKey:@"UNIQUE_KEY"]; // remove connection listener

Channel event

Channel events convey all events that occur between the user and the channel.

Channel event types

Event Name Occurrence Time Description
OnEnteredMember Member Channel Participation Occurs when a member joins the channel. An object containing the information of the member who joined (EnteredMember) is passed.
OnExitedMember Member Channel Exit Occurs when a member exits the channel. An object containing the information of the member who exited (ExitedMember) is passed.
OnDeletedChannel Channel Deletion Occurs when a channel is deleted. An object containing the information of the deleted channel (DeletedChannel) is passed.
OnNoticeMessage Notice Message Reception [Deprecated] Occurs when a notice message is received. An object containing the information of the notice message (ChannelNoticeMessage) is passed.
OnChannelSystemMessage Notice Message Reception Occurs when a notice message is received. Passes an object containing notice message information (ChannelSystemMessage).
OnChannelMessage Channel Message Reception Occurs when a channel message is received. An object containing the information of the channel message (ChannelMessage) is passed.
OnSetReaction Reaction Set Occurs when a reaction is set or replaced on a channel message. An object containing the reaction information (MessageReactionEvent) is passed.
OnClearReaction Reaction Cleared Occurs when a reaction is cleared from a channel message. An object containing the cleared reaction information (MessageReactionEvent) is passed.

Enteredmember

Field Name Description Type
channelId Channel ID where the event occurred string
playerId PlayerID of the member who entered int
timestamp Event occurrence time string
timestampMillis Event occurrence time (Unix Timestamp) string

Exitedmember

Field Name Description Type
channelId The ID of the channel where the event occurred string
playerId The PlayerID of the member who left int
timestamp The time the event occurred string
timestampMillis The time the event occurred (Unix Timestamp) string

Deletedchannel

Field Name Description Type
channelId Deleted channel ID string
timestamp Event occurrence time string
timestampMillis Event occurrence time (Unix Timestamp) string

Channelnoticemessage

Field Name Description Type
channelId The ID of the channel where the event occurred string
from The sender of the notification message string
message The notification message string
timestamp The time the event occurred string
timestampMillis The event occurrence time (Unix Timestamp) string

ChannelSystemMessage

Field Name Description Type
category Message category. Always GAME_SYSTEM for game system messages. string
messageId Unique message identifier string
channelId ID of the channel that received the system message string
messageType System message type defined by the game. Consists of uppercase English letters, numbers, and underscores (_).
Example: GUILD_MEMBER_JOINED
string
fallbackMessage Default display text. Display this text as is if the game does not compose the message directly using messageArgs. string
messageArgs Arguments for composing the message. An empty value is passed if the server omits them. map<string, string>
timestampMillis System message transmission time in Unix Timestamp format long

Channelmessage

Field Name Description Type
messageId Unique message identifier string
channelId Channel ID where the event occurred string
from Message sender string
to Receiving channel string
message Message string
translated Translation status boolean
translatedMessage Translated message string
extraData Additional information for the channel message string
timestamp Event occurrence time string
timestampMillis Event occurrence time (Unix Timestamp) string
replyMessageId Reply target message ID (received only when a reply target message ID is specified in ChannelSendMessageParams when sending a channel message) string
replyMessage Reply target message content (received only when a reply target message ID is specified in ChannelSendMessageParams when sending a channel message) string
replyExtraData Reply target message extra information (received only when a reply target message ID is specified in ChannelSendMessageParams when sending a channel message) string
mentionedPlayerIds Mentioned player IDs list<long>
reactions Reaction information map<ReactionType, list<long>>
messageReaction Reaction summary for the message MessageReaction

Reaction

Field Name Description Type
channelId Channel ID where the reaction event occurred string
messageId Message ID where the reaction event occurred string
playerId Player ID who triggered the reaction event long
type Reaction type (ReactionType) enum

MessageReactionEvent

Field Name Description Type
channelId Channel ID where the reaction event occurred string
messageId Message ID where the reaction event occurred string
playerId Player ID who set or cleared the reaction long
reactionIndex Reaction index that was set or cleared. 1-200 integer
using hive;

ChannelHandler channelHandler = new ChannelHandler
{
    OnEnteredMember = (member) =>
    {
        // member entered
    },
    OnExitedMember = (member) =>
    {
        // member exited
    },
    OnDeletedChannel = (channel) =>
    {
        // channel deleted
    },
    OnNoticeMessage = (message) =>
    {
        // channel notice message received
        // deprecated 26.8.0
    },
    OnChannelSystemMessage = (message) =>
    {
        // channel system message received
    },
    OnChannelMessage = (message) =>
    {
        // channel message received
    },
    OnAddReaction = (reaction) =>
    {
        // add reaction
    },
    OnRemoveReaction = (reaction) =>
    {
        // remove reaction
    }
};
Chat.addChannelHandler("UNIQUE_KEY", channelHandler); // add channel handler
Chat.removeChannelHandler("UNIQUE_KEY"); // remove channel handler
#include "HiveChat.h"

class ChannelListener : public FHiveChannelListener {
public:
    UChatTestView* Owner;
    ChannelListener(UChatTestView* InOwner) : Owner(InOwner) {}

    virtual void onNoticeMessage(const FHiveChannelNoticeMessage& message) override {
        // channel notice message received
        // deprecated 26.8.0
    }

    virtual void onChannelSystemMessage(const FHiveChannelSystemMessage& message) override {
        // channel system message received
    }

    virtual void onChannelMessage(const FHiveChannelMessage& message) override {
        // channel message received
    }

    virtual void onDeletedChannel(const FHiveDeletedChannel& channel) override {
        // channel deleted
    }

    virtual void onEnteredMember(const FHiveEnteredMember& member) override {
        // member entered
    }

    virtual void onExitedMember(const FHiveExitedMember& member) override {
        // member exited
    }

    virtual void onAddReaction(const FHiveReaction& reaction) override {
        // add reaction
    }

    virtual void onRemoveReaction(const FHiveReaction& reaction) override {
        // remove reaction
    }
};

FHiveChat::AddChannelListener("UNIQUE_KEY", new ChannelListener(this)); // add channel listener
FHiveChat::RemoveChannelListener("UNIQUE_KEY"); // remove channel listener
#include <HIVE_SDK_Plugin/HIVE_CPP.h>
using namespace hive;

class ChannelListenerImpl : public ChannelListener {
    void onEnteredMember(EnteredMember const & member) override {
        // member entered
    }

    void onExitedMember(ExitedMember const & member) override {
        // member exited
    }

    void onDeletedChannel(DeletedChannel const & channel) override {
        // channel deleted
    }

    void onNoticeMessage(ChannelNoticeMessage const & message) override {
        // channel notice message received
        // deprecated 26.8.0
    }

    void onChannelSystemMessage(ChannelSystemMessage const & message) override {
        // channel system message received
    }

    void onChannelMessage(ChannelMessage const & message) override {
        // channel message received
    }

    void onAddReaction(Reaction const & reaction) override {
        // add reaction
    }

    void onRemoveReaction(Reaction const & reaction) override {
        // remove reaction
    }

    void onSetReaction(MessageReactionEvent const & reaction) override {
        // set reaction
    }

    void onClearReaction(MessageReactionEvent const & reaction) override {
        // clear reaction
    }
};

Chat::addChannelListener("UNIQUE_KEY", new ChannelListenerImpl()); // add channel listener
Chat::removeChannelListener("UNIQUE_KEY"); // remove channel listener
import com.hive.Chat;

// add channel listener
Chat.addChannelListener("UNIQUE_KEY", object: Chat.ChannelListener{
    override fun onEnteredMember(member: Chat.EnteredMember) {
        // member entered
    }

    override fun onExitedMember(member: Chat.ExitedMember) {
        // member exited
    }

    override fun onDeletedChannel(channel: Chat.DeletedChannel) {
        // channel deleted
    }

    override fun onNoticeMessage(message: Chat.ChannelNoticeMessage) {
        // channel notice message received
        // deprecated 26.8.0
    }

    override fun onChannelSystemMessage(message: Chat.ChannelSystemMessage) {
        // channel system message received
    }

    override fun onChannelMessage(message: Chat.ChannelMessage) {
        // channel message received
    }

    override fun onAddReaction(reaction: Chat.Reaction) {
        // add reaction
    }

    override fun onRemoveReaction(reaction: Chat.Reaction) {
        // remove reaction
    }

    override fun onSetReaction(reaction: Chat.MessageReactionEvent) {
        // set reaction
    }

    override fun onClearReaction(reaction: Chat.MessageReactionEvent) {
        // clear reaction
    }
})

// remove channel listener
Chat.removeChannelListener("UNIQUE_KEY"); 
import com.hive.Chat;

// add channel listener
Chat.addChannelListener("UNIQUE_KEY", new Chat.ChannelListener(){
    @Override
    public void onEnteredMember(@NonNull Chat.EnteredMember member) {
        // member entered
    }

    @Override
    public void onExitedMember(@NonNull Chat.ExitedMember member) {
        // member exited
    }

    @Override
    public void onDeletedChannel(@NonNull Chat.DeletedChannel channel) {
        // channel deleted
    }

    @Override
    public void onNoticeMessage(@NonNull Chat.ChannelNoticeMessage message) {
        // channel notice message received
        // deprecated 26.8.0
    }

    @Override
    public void onChannelSystemMessage(@NonNull Chat.ChannelSystemMessage message) {
        // channel system message received
    }

    @Override
    public void onChannelMessage(@NonNull Chat.ChannelMessage message) {
        // channel message received
    }

    @Override
    public void onAddReaction(@NonNull Chat.Reaction reaction) {
        // add reaction
    }

    @Override
    public void onRemoveReaction(@NonNull Chat.Reaction reaction) {
        // remove reaction
    }

    @Override
    public void onSetReaction(@NonNull Chat.MessageReactionEvent reaction) {
        // set reaction
    }

    @Override
    public void onClearReaction(@NonNull Chat.MessageReactionEvent reaction) {
        // clear reaction
    }
});

// remove channel listener
Chat.removeChannelListener("UNIQUE_KEY");
import HIVEService

class ChatChannelListener: HiveChatChannelDelegate {
    func onEnteredMember(member: HiveChatEnteredMember) {
        // member entered
    }

    func onExitedMember(member: HiveChatExitedMember) {
        // member exited
    }

    func onDeletedChannel(channel: HiveChatDeletedChannel) {
        // channel deleted
    }

    func onChannelNoticeMessage(message: ChannelNoticeMessage) {
        // channel notice message received
        // deprecated 26.8.0
    }

    func onChannelSystemMessage(message: ChannelSystemMessage) {
        // channel system message received
    }

    func onChannelMessage(message: ChannelMessage) {
        // channel message received
    }

    func onAddReaction(reaction: HiveChatParams.Reaction) {
        // add reaction
    }

    func onRemoveReaction(reaction: HiveChatParams.Reaction) {
        // remove reaction
    }

    func onSetReaction(reaction: HiveChatParams.MessageReactionEvent) {
        // set reaction
    }

    func onClearReaction(reaction: HiveChatParams.MessageReactionEvent) {
        // clear reaction
    }
}

ChatInterface.addChannelListener(uniqueKey: "UNIQUE_KEY", listener: ChatChannelListener()) // add channel listener
ChatInterface.removeChannelListener(uniqueKey: "UNIQUE_KEY") // remove channel listener
#import "HIVEService.h"

@interface ChatChannelListener : NSObject <HiveChatChannelDelegate>
@end

@implementation ChatChannelListener
- (void)onEnteredMemberWithMember:(HiveChatEnteredMember *)member {
    // member entered
}

- (void)onExitedMemberWithMember:(HiveChatExitedMember *)member {
    // member exited
}

- (void)onDeletedChannelWithChannel:(HiveChatDeletedChannel *)channel {
    // channel deleted
}

- (void)onChannelNoticeMessageWithMessage:(HiveChatChannelNoticeMessage *)message {
    // channel notice message received
    // deprecated 26.8.0
}

- (void)onChannelSystemMessageWithMessage:(HiveChatChannelSystemMessage *)message {
    // channel system message received
}

- (void)onChannelMessageWithMessage:(HiveChatChannelMessage *)message {
    // channel message received
}

- (void)onAddReactionWithReaction:(HiveChatReaction *)reaction {
    // add reaction
}

- (void)onRemoveReactionWithReaction:(HiveChatReaction *)reaction {
    // remove reaction
}

- (void)onSetReactionWithReaction:(HiveChatMessageReactionEvent *)reaction {
    // set reaction
}

- (void)onClearReactionWithReaction:(HiveChatMessageReactionEvent *)reaction {
    // clear reaction
}
@end

[HiveChat addChannelListenerWithUniqueKey:@"UNIQUE_KEY" listener:[[ChatChannelListener alloc] init]]; // add channel listener
[HiveChat removeChannelListenerWithUniqueKey:@"UNIQUE_KEY"]; // remove channel listener

Channel event history

Retrieves channel event history.

GetSystemMessage

Retrieves the notice message history delivered through OnChannelSystemMessage.

To retrieve past channel system messages that were not received in real time, create a SystemMessageListQueryParams object and call the getSystemMessages() method of the Chat class. A chat server session is required, so call this method only while connected to the socket.

If hasNext in the response is true, pass nextMessageId as messageId in the next query to retrieve the next page. The server stores and queries system messages separately from regular chat messages and does not return the two lists combined.

SystemMessageListQueryParams

Field Name Description Type Required
size Number of messages to retrieve. Minimum 1, maximum 50.
If 0, uses the server default of 10.
integer N
messageType System message type to retrieve.
If empty, retrieves all types.
string N
messageId Query cursor. Pass nextMessageId from the previous query result.
Omit for the first query.
string N

ChannelSystemMessageListQueryResponse

Field Name Description Type
hasNext Whether there are more messages to retrieve boolean
nextMessageId Message ID to pass when retrieving additional messages string
content Retrieved system messages, sorted from newest to oldest list<ChannelSystemMessage>

The following example retrieves 10 system messages of a specific type.

using hive;

SystemMessageListQueryParams queryParams = new SystemMessageListQueryParams();
queryParams.size = 10;
queryParams.messageType = "GUILD_MEMBER_JOINED"; // Retrieve all types if omitted
queryParams.messageId = "NEXT_MESSAGE_ID";       // Omit for the first query

Chat.getSystemMessages("CHANNEL_ID", queryParams, (ResultAPI result, ChannelSystemMessageListQueryResponse response) => {
    if (result.isSuccess() && response != null) {
        foreach (ChannelSystemMessage message in response.content) {
            // channel system message list
        }
        if (response.hasNext) {
            // pass response.nextMessageId as messageId of the next query
        }
    }
});
#include "HiveChat.h"

FHiveSystemMessageListQueryParams QueryParams = FHiveSystemMessageListQueryParams();
QueryParams.size = 10;
QueryParams.messageType = TEXT("GUILD_MEMBER_JOINED"); // Retrieve all types if omitted
QueryParams.messageId = TEXT("NEXT_MESSAGE_ID");       // Omit for the first query

FHiveChat::GetSystemMessages(TEXT("CHANNEL_ID"), QueryParams, FHiveChatOnGetSystemMessagesDelegate::CreateLambda([this](const FHiveResultAPI& Result, const FHiveChannelSystemMessageListQueryResponse& Response) {
    if (Result.IsSuccess()) {
        for (const FHiveChannelSystemMessage& Message : Response.content) {
            // channel system message list
        }
        if (Response.hasNext) {
            // pass Response.nextMessageId as messageId of the next query
        }
    }
}));
#include <HIVE_SDK_Plugin/HIVE_CPP.h>
using namespace hive;

SystemMessageListQueryParams queryParams;
queryParams.size = 10;
queryParams.messageType = "GUILD_MEMBER_JOINED"; // Retrieve all types if omitted
queryParams.messageId = "NEXT_MESSAGE_ID";       // Omit for the first query

Chat::getSystemMessages("CHANNEL_ID", queryParams, [=](ResultAPI const & result, ChannelSystemMessageListQueryResponse const & response) {
    if (result.isSuccess()) {
        for (auto message : response.content) {
            // channel system message list
        }
        if (response.hasNext) {
            // pass response.nextMessageId as messageId of the next query
        }
    }
});
import com.hive.Chat;
import com.hive.ResultAPI;

val queryParams = Chat.SystemMessageListQueryParams(
    size = 10,
    messageType = "GUILD_MEMBER_JOINED", // Retrieve all types if omitted
    messageId = "NEXT_MESSAGE_ID"        // Omit for the first query
)

Chat.getSystemMessages("CHANNEL_ID", queryParams, object : Chat.GetChannelSystemMessagesListener {
    override fun onResult(
        result: ResultAPI,
        response: Chat.ChannelSystemMessageListQueryResponse?
    ) {
        if (result.isSuccess && response != null) {
            response.content.forEach { message ->
                // channel system message list
            }
            if (response.hasNext) {
                // pass response.nextMessageId as messageId of the next query
            }
        }
    }
})
import com.hive.Chat;

Chat.SystemMessageListQueryParams queryParams = new Chat.SystemMessageListQueryParams(
    10,                      // size
    "GUILD_MEMBER_JOINED",   // messageType, null if omitted
    "NEXT_MESSAGE_ID"        // messageId, null for the first query
);

Chat.getSystemMessages("CHANNEL_ID", queryParams, (result, response) -> {
    if (result.isSuccess() && response != null) {
        for (Chat.ChannelSystemMessage message : response.getContent()) {
            // channel system message list
        }
        if (response.getHasNext()) {
            // pass response.getNextMessageId() as messageId of the next query
        }
    }
});
import HIVEService

let queryParams = HiveChatParams.SystemMessageListQueryParams(
    size: 10,
    messageType: "GUILD_MEMBER_JOINED", // nil if omitted
    messageId: "NEXT_MESSAGE_ID"        // nil for the first query
)

ChatInterface.getSystemMessages(channelId: "CHANNEL_ID", params: queryParams) { result, response in
    if result.isSuccess(), let response = response {
        response.content.forEach { message in
            // channel system message list
        }
        if response.hasNext {
            // pass response.nextMessageId as messageId of the next query
        }
    }
}
#import "HIVEService.h"

HiveChatSystemMessageListQueryParams* queryParams = [HiveChatSystemMessageListQueryParams new];
queryParams.size = 10;
queryParams.messageType = @"GUILD_MEMBER_JOINED"; // nil if omitted
queryParams.messageId = @"NEXT_MESSAGE_ID";       // nil for the first query

[HiveChat getSystemMessagesWithChannelId:@"CHANNEL_ID" params:queryParams handler:^(HIVEResultAPI * result, HiveChatChannelSystemMessageListQueryResponse* response) {
    if ([result isSuccess] && response != nil) {
        for (HiveChatChannelSystemMessage *message in response.content) {
            // channel system message list
        }
        if (response.hasNext) {
            // pass response.nextMessageId as messageId of the next query
        }
    }
}];

User event

User events deliver direct message and notice delivery events.

User event types

Event Name Occurrence Time Description
OnDirectMessage When receiving a direct message Occurs when a direct message is received. Passes an object (DirectMessage) containing direct message information.
onNoticeMessage When receiving a notice message Occurs when a notice message is received. It delivers an object containing the notice message information (NoticeMessage).

Directmessage

Field Name Description Type
messageId Unique message identifier string
from Message Sender long
to Message Receiver long
message Message string
extraData Additional direct message information string
timestamp Event Occurrence Time string
timestampMillis Event Occurrence Time (Unix Timestamp) string

Noticemessage

Field Name Description Type
from Message Sender string
message Message string
timestamp Event Occurrence Time string
timestampMillis Event Occurrence Time (Unix Timestamp) string
using hive;

UserHandler userHandler = new UserHandler
{
    OnDirectMessage = (message) =>
    {
        // direct message received
    },
    OnNoticeMessage = (message) =>
    {
        // notice message Received
    }
};
Chat.addUserHandler("UNIQUE_KEY", userHandler); // add user handler
Chat.removeUserHandler("UNIQUE_KEY"); // remove user handler
class UserListener : public FHiveUserListener {
public:
    UChatTestView* Owner;
    UserListener(UChatTestView* InOwner) : Owner(InOwner) {}

    virtual void onDirectMessage(const FHiveDirectMessage& message) override {
        // direct message received
    }

    virtual void onNoticeMessage(const FHiveNoticeMessage& message) override {
        // notice message received
    }
};

FHiveChat::AddUserListener("UNIQUE_KEY", new UserListener(this)); // add user listener

FHiveChat::RemoveUserListener("UNIQUE_KEY"); // remove user listener
#include <HIVE_SDK_Plugin/HIVE_CPP.h>
using namespace hive;

class UserListenerImpl : public UserListener {
    void onDirectMessage(DirectMessage const & message) override {
        // direct message received
    }

    void onNoticeMessage(NoticeMessage const & message) override {
        // notice message received
    }
};

Chat::addUserListener("UNIQUE_KEY", new UserListenerImpl()); // add user listener
Chat::removeUserListener("UNIQUE_KEY"); // remove user listener
import com.hive.Chat;

// add user listener
Chat.addUserListener("UNIQUE_KEY", object: Chat.UserListener{
    override fun onDirectMessage(message: Chat.DirectMessage) {
        // direct message received
    }

    override fun onNoticeMessage(message: Chat.NoticeMessage) {
        // notiice message received
    }
})

// remove user listener
Chat.removeUserListener("UNIQUE_KEY");
import com.hive.Chat;

// add direct message listener
Chat.addUserListener("UNIQUE_KEY", new Chat.UserListener() {
    @Override
    public void onDirectMessage(@NonNull Chat.DirectMessage message) {
        // direct message received
    }

    @Override
    public void onNoticeMessage(@NonNull Chat.NoticeMessage message) {
        // notice message received
    }
});

// remove user listener
Chat.removeUserListener("UNIQUE_KEY");
import HIVEService

class ChatUserListener: HiveChatUserDelegate {
    func onDirectMessage(_ message: HiveChatParams.DirectMessage) {
        // direct message received
    }

    func onNoticeMessage(_ message: HiveChatParams.NoticeMessage) {
        // notice message received
    }
}

ChatInterface.addUserListener(uniqueKey: "UNIQUE_KEY", listener: HiveChatUserDelegate()) // add user listener
ChatInterface.removeUserListener(uniqueKey: "UNIQUE_KEY") // remove user listener
#import "HIVEService.h"

@interface ChatUserListener : NSObject <HiveChatUserDelegate>
@end

@implementation ChatUserListener
- (void)onDirectMessage:(HiveChatDirectMessage *)message {
    // direct message received
}

- (void)onNoticeMessage:(HiveChatNoticeMessage)message {
    // notice message received
}
@end

[HiveChat addUserListenerWithUniqueKey:@"UNIQUE_KEY" listener:[[HiveChatUserDelegate alloc] init]]; // add user listener
[HiveChat removeUserListenerWithUniqueKey:@"UNIQUE_KEY"]; // remove user listener

Custom data event

Receives custom data delivered through the Hive Chat API Send channel custom message or Send user custom message.

Note

The Hive SDK does not send custom data. Send custom data through the Hive Chat API.

Custom data event type

Event Name Occurrence Time Description
OnCustomData When custom data is received Occurs when custom data is received. It transmits custom data of type string.
(Maximum 8000 byte)
using hive;

CustomDataHandler customDataHandler = new CustomDataHandler
{
    OnCustomData = (data) =>
    {
        // custom data received
    }
};
Chat.addCustomDataHandler("UNIQUE_KEY", customDataHandler); // add custom data handler
Chat.removeCustomDataHandler("UNIQUE_KEY"); // remove custom data handler
class CustomDataListener : public FHiveCustomDataListener {
public:
    UChatTestView* Owner;
    CustomDataListener(UChatTestView* InOwner) : Owner(InOwner) {}

    virtual void onCustomData(const FString data) override {
        // custom data received
    }
};

FHiveChat::AddCustomDataListener("UNIQUE_KEY", new CustomDataListener(this)); // add custom data listener

FHiveChat::RemoveCustomDataListener("UNIQUE_KEY"); // remove custom data listener
#include <HIVE_SDK_Plugin/HIVE_CPP.h>
using namespace hive;

class CustomDataListenerImpl : public CustomDataListener {
    void onCustomData(std::string const & data) override {
        // custom data received
    }
};

Chat::addCustomDataListener("UNIQUE_KEY", new CustomDataListenerImpl()); // add custom data listener
Chat::removeCustomDataListener("UNIQUE_KEY"); // remove custom data listener
import com.hive.Chat;

// add custom data listener
Chat.addCustomDataListener("UNIQUE_KEY", object: Chat.CustomDataListener{
    override fun onCustomData(data: String) {
        // custom data received
    }
})

// remove custom data listener
Chat.removeCustomDataListener("UNIQUE_KEY");
import com.hive.Chat;

// add custom data listener
Chat.addCustomDataListener("UNIQUE_KEY", new Chat.CustomDataListener() {
    @Override
    public void onCustomData(@NonNull String data) {
        // custom data received
    }
});

// remove custom data listener
Chat.removeCustomDataListener("UNIQUE_KEY");
import HIVEService

class ChatCustomDataListener: HiveChatCustomDataDelegate {
    func onCustomData(_ data: String) {
        // custom data received
    }
}

ChatInterface.addCustomDataListener(uniqueKey: "UNIQUE_KEY", listener: HiveChatCustomDataDelegate()) // add custom data listener
ChatInterface.removeCustomDataListener(uniqueKey: "UNIQUE_KEY") // remove custom data listener
#import "HIVEService.h"

@interface ChatCustomDataListener : NSObject <HiveChatCustomDataDelegate>
@end

@implementation ChatCustomDataListener
- (void)onCustomData:(NSString *)data {
    // custom data received
}
@end

[HiveChat addCustomDataListenerWithUniqueKey:@"UNIQUE_KEY" listener:[[HiveChatCustomDataDelegate alloc] init]]; // add custom data listener
[HiveChat removeCustomDataListenerWithUniqueKey:@"UNIQUE_KEY"]; // remove custom data listener