Skip to content

Message

The Hive chat feature supports channel message sending to send messages to channels the user participates in, and 1:1 message sending to send messages directly to specific individuals.

Channel message sending

To send a message to a channel that the user has participated in, create a ChannelSendMessageParams object and then pass it as an argument to the Chat class's sendMessage() method to call it.

Channelsendmessageparams

Field Name Description Type Required
channelId Channel ID to send the channel message string Y
message Message to send to the channel
(up to 200 characters)
string Y

This is an example code that sends a message to the channels the user has participated in.

using hive;

ChannelSendMessageParams channelSendMessageParams = new ChannelSendMessageParams();
channelSendMessageParams.channelId = "CHANNEL_ID";
channelSendMessageParams.message = "Hello Hive";

Chat.sendMessage(channelSendMessageParams);
#include <HIVE_SDK_Plugin/HIVE_CPP.h>
using namespace hive;

ChannelSendMessageParams params;
params.channelId = "CHANNEL_ID";
params.message = "Hello Hive";

Chat::sendMessageWithChannelSendMessageParams(params, [=](ResultAPI const & result) {
    if (result.isSuccess()) {
        // API Call Success
    }
});
import com.hive.Chat;
import com.hive.ResultAPI;

val params = Chat.ChannelSendMessageParams(
    channelId = "CHANNEL_ID",
    message = "Hello Hive"
)
Chat.sendMessage(params)
import com.hive.Chat;

Chat.ChannelSendMessageParams params = new Chat.ChannelSendMessageParams(
    "CHANNEL_ID",
    "Hello Hive"
);

Chat.sendMessage(params);
import HIVEService

let params = HiveChatParams.ChannelSendMessageParams(
    channelId = "CHANNEL_ID",
    message = "Hello Hive"
)
ChatInterface.sendMessage(params)
#import "HIVEService.h"

HiveChatChannelSendMessageParams* sendMessageParams = [[HiveChatChannelSendMessageParams alloc] init];
sendMessageParams.channelId = "CHANNEL_ID";
sendMessageParams.message = "Hello Hive";

[HiveChat sendMessageWithChannelSendMessageParams:sendMessageParams handler:nil];

Channel message event management

The sent message can be received by the onChannelMessage event handler of the addChannelListener event. For more details on event handling, please refer to the Event Management > Channel Events document.

1:1 message sending

To send a direct message to a specific recipient, the user creates a DirectSendMessageParams object and then passes it as an argument to the Chat class's sendMessage() method.

Directsendmessageparams

Field Name Description Type Required
toPlayerId Hive player ID of the target user long Y
message Message to be sent to the channel
(up to 200 characters)
string Y

The following is an example code for a user to send a direct message to a specific recipient.

using hive;

DirectSendMessageParams directSendMessageParams = new DirectSendMessageParams();
directSendMessageParams.toPlayerId = 12345678;
directSendMessageParams.message = "Hello Hive";

Chat.sendMessage(directSendMessageParams);
import com.hive.Chat;
import com.hive.ResultAPI;

val params = Chat.DirectSendMessageParams(
    toPlayerId = 12345678,
    message = message
)

Chat.sendMessage(params)
#include <HIVE_SDK_Plugin/HIVE_CPP.h>
using namespace hive;

DirectSendMessageParams params;
params.toPlayerId = 12345678;
params.message = "Hello Hive";

Chat::sendMessageWithDirectSendMessageParams(params);
import com.hive.Chat;

Chat.DirectSendMessageParams params = new Chat.DirectSendMessageParams(
        12345678,
        "Hello Hive"
);

Chat.sendMessage(params);
import HIVEService

let params = HiveChatParams.DirectSendMessageParams(toPlayerId: Int64(12345678), message: "Hello Hive")

ChatInterface.sendMessage(sendMessageParams: params)
#import "HIVEService.h"

HiveChatDirectSendMessageParams* sendMessageParams = [[HiveChatDirectSendMessageParams alloc] init];
sendMessageParams.toPlayerId = 12345678;
sendMessageParams.message = "Hello Hive";

[HiveChat sendDirectMessageWithSendMessageParams:sendMessageParams handler:nil];

1:1 message event management

Messages sent through 1:1 message transmission can be received via the addDirectMessageListener event handler onDirectMessage event. For detailed event handling methods, please refer to the Event Management > 1:1 Message Event document.