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 joined, create a ChannelSendMessageParams
object and pass it as an argument to the Chat class's sendMessage()
method.
sendMessage()
method returns the transmission result and the ChannelSendMessageParams
used for sending as retryParam
. If the transmission fails, you can attempt to resend using retryParams
.
Channelsendmessageparams¶
Field Name | Description | Type | Required |
---|---|---|---|
channelId | Channel ID to send the message | string | Y |
message | Message to send to the channel (up to 200 characters) | string | Y |
extraData | Additional information for the channel message up to 256B Byte (UTF-8) | string | N |
replyMessageId | Message ID being replied to | string | N |
mentionedPlayerIds | Player IDs to mention | list <long> | N |
This is an example code that sends messages to channels the user has participated in.
using hive;
ChannelSendMessageParams channelSendMessageParams = new ChannelSendMessageParams();
channelSendMessageParams.channelId = "CHANNEL_ID";
channelSendMessageParams.message = "Hello Hive";
channelSendMessageParams.extraData = "EXTRA_DATA";
Chat.sendMessage(channelSendMessageParams, (ResultAPI result, ChannelSendMessageParams retryParams) => {
if (!result.isSuccess()) {
// Message Send Failed, Try resending using `retryParams`
}
});
#include "HiveChat.h"
FHiveChatChannelSendMessageParams ChannelSendMessageParams;
ChannelSendMessageParams.ChannelId = TEXT("CHANNEL_ID");
ChannelSendMessageParams.Message = TEXT("Hello Hive");
ChannelSendMessageParams.ExtraData = TEXT("EXTRA_DATA");
FHiveChat::SendMessageWithChannelSendMessageParams(ChannelSendMessageParams, FHiveChatOnResultDelegate::CreateLambda([this](const FHiveResultAPI& Result, const FHiveChatChannelSendMessageParams& RetryParams) {
if (!Result.IsSuccess) {
// Message Send Failed, Try resending using `RetryParams`
}
}));
#include <HIVE_SDK_Plugin/HIVE_CPP.h>
using namespace hive;
ChannelSendMessageParams params;
params.channelId = "CHANNEL_ID";
params.message = "Hello Hive";
params.extraData = "EXTRA_DATA";
Chat::sendMessageWithChannelSendMessageParams(params, [=](ResultAPI const & result, ChannelSendMessageParams const & retryParams) {
if (!result.isSuccess()) {
// Message Send Failed, Try resnding using `retryParams`
}
});
import com.hive.Chat;
import com.hive.ResultAPI;
val params = Chat.ChannelSendMessageParams(
channelId = "CHANNEL_ID",
message = "Hello Hive",
extraData = "EXTRA_DATA"
)
Chat.sendMessage(params, object: Chat.SendMessageListener {
override fun onResult(
result: ResultAPI,
retryParams: Chat.ChannelSendMessageParams?
) {
if (!result.isSuccess) {
// Message Send Failed, Try resending using `retryParams`
}
}
})
#import "HIVEService.h"
HiveChatChannelSendMessageParams* sendMessageParams = [[HiveChatChannelSendMessageParams alloc] init];
sendMessageParams.channelId = "CHANNEL_ID";
sendMessageParams.message = "Hello Hive";
sendMessageParams.extraData = "EXTRA_DATA";
[HiveChat sendMessageWithChannelSendMessageParams:sendMessageParams handler:^(HIVEResultAPI * result, HiveChatChannelSendMessageParams * retryParams) {
if (!result.isSuccess) {
// Message Send Failed. Try resending using `retryParams`
}
}];
The following is an example code for sending a reply to a specific target message in a channel the user has joined.
using hive;
ChannelSendMessageParams channelSendMessageParams = new ChannelSendMessageParams();
channelSendMessageParams.channelId = "CHANNEL_ID";
channelSendMessageParams.message = "Hello Hive";
channelSendMessageParams.replyMessageId = "TARGET_MESSAGE_ID";
Chat.sendMessage(channelSendMessageParams, (ResultAPI result, ChannelSendMessageParams retryParams) => {
if (!result.isSuccess()) {
// Message Send Failed, Try resending using `retryParams`
}
});
#include "HiveChat.h"
FHiveChatChannelSendMessageParams ChannelSendMessageParams;
ChannelSendMessageParams.ChannelId = TEXT("CHANNEL_ID");
ChannelSendMessageParams.Message = TEXT("Hello Hive");
ChannelSendMessageParams.ReplyMessageId = TEXT("TARGET_MESSAGE_ID");
FHiveChat::SendMessageWithChannelSendMessageParams(ChannelSendMessageParams, FHiveChatOnResultDelegate::CreateLambda([this](const FHiveResultAPI& Result, const FHiveChatChannelSendMessageParams& RetryParams) {
if (!Result.IsSuccess) {
// Message Send Failed, Try resending using `RetryParams`
}
}));
#include <HIVE_SDK_Plugin/HIVE_CPP.h>
using namespace hive;
ChannelSendMessageParams params;
params.channelId = "CHANNEL_ID";
params.message = "Hello Hive";
params.replyMessageId = "TARGET_MESSAGE_ID";
Chat::sendMessageWithChannelSendMessageParams(params, [=](ResultAPI const & result, ChannelSendMessageParams const & retryParams) {
if (!result.isSuccess()) {
// Message Send Failed, Try resnding using `retryParams`
}
});
import com.hive.Chat;
import com.hive.ResultAPI;
val params = Chat.ChannelSendMessageParams(
channelId = "CHANNEL_ID",
message = "Hello Hive",
replyMessageId = "TARGET_MESSAGE_ID"
)
Chat.sendMessage(params, object: Chat.SendMessageListener {
override fun onResult(
result: ResultAPI,
retryParams: Chat.ChannelSendMessageParams?
) {
if (!result.isSuccess) {
// Message Send Failed, Try resending using `retryParams`
}
}
})
import com.hive.Chat;
Chat.ChannelSendMessageParams params = new Chat.ChannelSendMessageParams(
"CHANNEL_ID",
"Hello Hive",
"EXTRA_DATA",
"TARGET_MESSAGE_ID"
);
Chat.sendMessage(params, (result, retryParams) -> {
if(!result.isSuccess()) {
// Message Send Failed, Try resending using `retryParams`
}
});
import HIVEService
let params = HiveChatParams.ChannelSendMessageParams(
channelId = "CHANNEL_ID",
message = "Hello Hive",
replyMessageId = "TARGET_MESSAGE_ID"
)
ChatInterface.sendMessage(params) { result, retryParams in
if !result.isSuccess {
// Message Send Failed, Try resending using `retryParams`
}
}
#import "HIVEService.h"
HiveChatChannelSendMessageParams* sendMessageParams = [[HiveChatChannelSendMessageParams alloc] init];
sendMessageParams.channelId = "CHANNEL_ID";
sendMessageParams.message = "Hello Hive";
sendMessageParams.replyMessageId = "TARGET_MESSAGE_ID";
[HiveChat sendMessageWithChannelSendMessageParams:sendMessageParams handler:^(HIVEResultAPI * result, HiveChatChannelSendMessageParams * retryParams) {
if (!result.isSuccess) {
// Message Send Failed. Try resending using `retryParams`
}
}];
The following is an example code for sending a message mentioning specific users in a channel the user has joined.
using hive;
ChannelSendMessageParams channelSendMessageParams = new ChannelSendMessageParams();
channelSendMessageParams.channelId = "CHANNEL_ID";
channelSendMessageParams.message = "Hello Hive";
List<long> playerIds = new List<long>();
playerIds.Add(1234); // User 1 PlayerId
playerIds.Add(5678); // User 2 PlayerId
channelSendMessageParams.mentionedPlayerIds = playerIds;
Chat.sendMessage(channelSendMessageParams, (ResultAPI result, ChannelSendMessageParams retryParams) => {
if (!result.isSuccess()) {
// Message Send Failed, Try resending using `retryParams`
}
});
#include "HiveChat.h"
FHiveChatChannelSendMessageParams ChannelSendMessageParams;
ChannelSendMessageParams.ChannelId = TEXT("CHANNEL_ID");
ChannelSendMessageParams.Message = TEXT("Hello Hive");
TArray<int64> PlayerIds;
PlayerIds.Add(1234); // User 1 PlayerId
PlayerIds.Add(5678); // User 2 PlayerId
ChannelSendMessageParams.MentionedPlayerIds = PlayerIds;
FHiveChat::SendMessageWithChannelSendMessageParams(ChannelSendMessageParams, FHiveChatOnResultDelegate::CreateLambda([this](const FHiveResultAPI& Result, const FHiveChatChannelSendMessageParams& RetryParams) {
if (!Result.IsSuccess) {
// Message Send Failed, Try resending using `RetryParams`
}
}));
#include <HIVE_SDK_Plugin/HIVE_CPP.h>
using namespace hive;
ChannelSendMessageParams params;
params.channelId = "CHANNEL_ID";
params.message = "Hello Hive";
std::vector<int64_t> playerIds;
playerIds.push_back(1234); // User 1 PlayerId
playerIds.push_back(5678); // User 2 PlayerId
params.mentionedPlayerIds = playerIds;
Chat::sendMessageWithChannelSendMessageParams(params, [=](ResultAPI const & result, ChannelSendMessageParams const & retryParams) {
if (!result.isSuccess()) {
// Message Send Failed, Try resnding using `retryParams`
}
});
import com.hive.Chat;
import com.hive.ResultAPI;
val playerIds = listOf(1234L, 5678L) // User 1, 2의 PlayerId
val params = Chat.ChannelSendMessageParams(
channelId = "CHANNEL_ID",
message = "Hello Hive",
replyMessageId = "TARGET_MESSAGE_ID",
mentionedPlayerIds = playerIds
)
Chat.sendMessage(params, object: Chat.SendMessageListener {
override fun onResult(
result: ResultAPI,
retryParams: Chat.ChannelSendMessageParams?
) {
if (!result.isSuccess) {
// Message Send Failed, Try resending using `retryParams`
}
}
})
import com.hive.Chat;
List<Long> mentionedPlayerIds = new ArrayList<>();
mentionedPlayerIds.add(1234L); // User 1 PlayerId
mentionedPlayerIds.add(5678L); // User 2 PlayerId
Chat.ChannelSendMessageParams params = new Chat.ChannelSendMessageParams(
"CHANNEL_ID",
"Hello Hive",
"EXTRA_DATA"
);
params.mentionedPlayerIds = mentionedPlayerIds;
Chat.sendMessage(params, (result, retryParams) -> {
if(!result.isSuccess()) {
// Message Send Failed, Try resending using `retryParams`
}
});
import HIVEService
var playerIds: [Int64] = [1234, 5678] // User 1, 2의 PlayerId
let params = HiveChatParams.ChannelSendMessageParams(
channelId = "CHANNEL_ID",
message = "Hello Hive",
mentionedPlayerIds = playerIds
)
ChatInterface.sendMessage(params) { result, retryParams in
if !result.isSuccess {
// Message Send Failed, Try resending using `retryParams`
}
}
#import "HIVEService.h"
HiveChatChannelSendMessageParams* sendMessageParams = [[HiveChatChannelSendMessageParams alloc] init];
sendMessageParams.channelId = @"CHANNEL_ID";
sendMessageParams.message = @"Hello Hive";
NSMutableArray<NSNumber *> *playerIds = [NSMutableArray array];
[playerIds addObject:@(1234)]; // 사용자 1 PlayerId
[playerIds addObject:@(5678)]; // 사용자 2 PlayerId
sendMessageParams.mentionedPlayerIds = playerIds;
[HiveChat sendMessageWithChannelSendMessageParams:sendMessageParams handler:^(HIVEResultAPI * result, HiveChatChannelSendMessageParams * retryParams) {
if (!result.isSuccess) {
// Message Send Failed. Try resending using `retryParams`
}
}];
Add or Remove Reactions to Channel Messages¶
Users can add or remove reactions to messages from specific users in channels they have joined. The message reaction feature allows users to easily express their feelings and provide quick feedback in real time, enabling more effective in-game communication. In particular, it helps make the flow of conversation in the channel more lively and intuitive.
Note
Currently, only the "Like" reaction type is supported. More reaction types will be added in the future.
Below is example code for adding or removing a reaction to a message from a specific user in a channel the user has joined.
using hive;
String messageId = "TARGET_MESSAGE_ID";
ReactionType type = ReactionType.Like;
channel.addReaction(messageId, type, (ResultAPI result, ReactionType reactionType) => {
if (result.isSuccess()) {
// API Call Success
}
});
channel.removeReaction(messageId, type, (ResultAPI result, ReactionType reactionType) => {
if (result.isSuccess()) {
// API Call Success
}
});
#include "HiveChat.h"
FString MessageId = TEXT("TARGET_MESSAGE_ID");
EReactionType Type = EReactionType::Like;
channel.AddReaction(MessageId, Type, FHiveChatOnReactionDelegate::CreateLambda([this](const FHiveResultAPI& Result, EReactionType Type) {
if (Result.IsSuccess()) {
// API Call Success
}
}));
channel.RemoveReaction(MessageId, Type, FHiveChatOnReactionDelegate::CreateLambda([this](const FHiveResultAPI& Result, EReactionType Type) {
if (Result.IsSuccess()) {
// API Call Success
}
}));
#include <HIVE_SDK_Plugin/HIVE_CPP.h>
using namespace hive;
std::string messageId = "TARGET_MESSAGE_ID";
ReactionType type = ReactionType::Like;
channel.addReaction(messageId, type, [=](ResultAPI const & result, ReactionType type) {
if (result.isSuccess()) {
// API Call Success
}
});
channel.removeReaction(messageId, type, [=](ResultAPI const & result, ReactionType type) {
if (result.isSuccess()) {
// API Call Success
}
});
import com.hive.Chat;
import com.hive.ResultAPI;
val messageId = "TARGET_MESSAGE_ID"
val type = Chat.ReactionType.Like;
channel.addReaction(messageId, type, object: Chat.ReactionListener {
override fun onResult(result: ResultAPI, type: Chat.ReactionType) {
if (result.isSuccess()) {
// API Call Success
}
}
})
channel.removeReaction(messageId, type, object: Chat.ReactionListener {
override fun onResult(result: ResultAPI, type: Chat.ReactionType) {
if (result.isSuccess()) {
// API Call Success
}
}
})
import com.hive.Chat;
String messageId = "TARGET_MESSAGE_ID";
Chat.ReactionType type = Chat.ReactionType.Like;
Chat.addReaction(messageId, type, new Chat.ReactionListener() {
@Override
public void onResult(ResultAPI result, ReactionType type) {
if (result.isSuccess()) {
// API Call Success
}
}
});
Chat.removeReaction(messageId, type, new Chat.ReactionListener() {
@Override
public void onResult(ResultAPI result, ReactionType type) {
if (result.isSuccess()) {
// API Call Success
}
}
});
import HIVEService
let messageId = "TARGET_MESSAGE_ID"
let reactionType: ReactionType = .like
ChatInterface.addReaction(messageId: messageId, type: reactionType) { result, type in
if result.isSuccess {
// API Call Success
}
}
ChatInterface.removeReaction(messageId: messageId, type: reactionType) { result, type in
if result.isSuccess {
// API Call Success
}
}
#import "HIVEService.h"
NSString *messageId = @"TARGET_MESSAGE_ID";
HiveChatReactionType reactionType = HiveChatReactionTypeLike;
[channel addReactionWithMessageId:messageId type:reactionType handler:^(ResultAPI *result, HiveChatReactionType type) {
if (result.isSuccess) {
// API Call Success
}
}];
[channel removeReactionWithMessageId:messageId type:reactionType handler:^(ResultAPI *result, HiveChatReactionType type) {
if (result.isSuccess) {
// API Call Success
}
}];
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.
sendMessage()
method returns the transmission result and the DirectSendMessageParams
used during transmission under the name retryParam
. If the transmission fails, you can attempt to resend using retryParams
.
Directsendmessageparams¶
Field Name | Description | Type | Required |
---|---|---|---|
toPlayerId | Hive player ID of the target user | long | Y |
message | Message to be sent to the target user (up to 200 characters) | string | Y |
extraData | Additional information for 1:1 message up to 256B Byte (UTF-8 standard) | string | N |
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";
directSendMessageParams.extraData = "EXTRA_DATA";
Chat.sendMessage(directSendMessageParams, (ResultAPI result, DirectSendMessageParams retryParams) => {
if (!result.isSuccess()) {
// Message Send Failed, Try resending using `retryParams`
}
});
#include "HiveChat.h"
FHiveChatDirectSendMessageParams DirectSendMessageParams = FHiveChatDirectSendMessageParams();
DirectSendMessageParams.ToPlayerId = 12345678l;
DirectSendMessageParams.Message = TEXT("Hello Hive");
DirectSendMessageParams.ExtraData = TEXT("EXTRA_DATA");
FHiveChat::SendMessageWithDirectSendMessageParams(DirectSendMessageParams, FHiveChatOnResultDelegate::CreateLambda([this](const FHiveResultAPI& Result, const FHiveChatDirectSendMessageParams& RetryParams) {
if (!Result.IsSuccess) {
// Message Send Failed, Try resending using `RetryParams`
}
}));
#include <HIVE_SDK_Plugin/HIVE_CPP.h>
using namespace hive;
DirectSendMessageParams params;
params.toPlayerId = 12345678;
params.message = "Hello Hive";
params.extraData = "EXTRA_DATA";
Chat::sendMessageWithDirectSendMessageParams(params, [=](ResultAPI const & result, DirectSendMessageParams const & retryParams) {
if (!result.isSuccess()) {
// Message Send Failed, Try resnding using `retryParams`
}
});
import com.hive.Chat;
import com.hive.ResultAPI;
val params = Chat.DirectSendMessageParams(
toPlayerId = 12345678,
message = "Hello Hive",
extraData = "EXTRA_DATA"
)
Chat.sendMessage(params, object: Chat.SendMessageListener {
override fun onResult(
result: ResultAPI,
retryParams: Chat.DirectSendMessageParams?
) {
if (!result.isSuccess) {
// Message Send Failed, Try resending using `retryParams`
}
}
})
import HIVEService
let params = HiveChatParams.DirectSendMessageParams(toPlayerId: Int64(12345678), message: "Hello Hive", extraData: "EXTRA_DATA")
ChatInterface.sendMessage(sendMessageParams: params) { result, retryParams in
if !result.isSuccess {
// Message Send Failed, Try resending using `retryParams`
}
}
#import "HIVEService.h"
HiveChatDirectSendMessageParams* sendMessageParams = [[HiveChatDirectSendMessageParams alloc] init];
sendMessageParams.toPlayerId = 12345678;
sendMessageParams.message = "Hello Hive";
sendMessageParams.extraData = "EXTRA_DATA";
[HiveChat sendDirectMessageWithSendMessageParams:sendMessageParams handler:^(HIVEResultAPI * result, HiveChatDirectSendMessageParams * retryParams) {
if (!result.isSuccess) {
// Message Send Failed. Try resending using `retryParams`
}
}];
1:1 message event management¶
Messages sent through 1:1 message transmission can be received via the onDirectMessage
event handler of the addUserListener
event. For more details on event handling, please refer to the Event Management > User Events document.
Message translation request¶
Attempting to request a translation for the message. The language code is based on ISO 639 alpha-2
standards.
Translateparams¶
Field Name | Description | Type | Required |
---|---|---|---|
message | Message | string | Y |
sourceLanguage | The language code of the message. If omitted, it is inferred as auto . | string | N |
targetLanguages | Array of language codes for translation requests | string array | Y |
using hive;
List<String> targetLanguages = new List<String>();
targetLanguages.Add("ko");
targetLanguages.Add("ja");
targetLanguages.Add("ar");
TranslateParams translateParams = new TranslateParams("hello", "auto", targetLanguages);
Chat.translate(translateParams, (ResultAPI result, TranslationData data) => {
if (result.isSuccess() && data != null) {
// data is translate languages
}
});
#include "HiveChat.h"
TArray<FString> TargetLanguages;
TargetLanguages.Add(TEXT("ko"));
TargetLanguages.Add(TEXT("ja"));
TargetLanguages.Add(TEXT("ar"));
FHiveChatTranslateParams TranslateParams = FHiveChatTranslateParams(TEXT("hello"), TEXT("auto"), TargetLanguages);
FHiveChat::Translate(TranslateParams, FHiveChatOnResultDelegate::CreateLambda([this](const FHiveResultAPI& Result, const FHiveChatTranslationData& data) {
if (Result.ISSuccess && data != null) {
// data is translate language messages
}
}));
#include <HIVE_SDK_Plugin/HIVE_CPP.h>
using namespace hive;
std::vector<std::string> targetLanguages = { "ko", "ja", "ar" };
Chat::TranslateParams translateParams = new Chat::TranslateParams("hello", "auto", targetLanguages);
Chat::translate(translateParams, [=](ResultAPI const & result, Chat::TranslationData const & data) {
if (!result.isSuccess() && data != null ) {
// data is translate language messages
}
});
import com.hive.Chat;
import com.hive.ResultAPI;
var translateParams = Chat.TranslateParams(
message = "hello",
sourceLanguage = "auto",
targetLanguages = ["ko", "ja", "ar"]
)
Chat.translate(translateParams, object: Chat.TranslateParamsListener {
override fun onResult(
result: ResultAPI,
data: Chat.TranslationData?
) {
if (!result.isSuccess && data != null) {
// data is translate language maessages
}
}
})
#import "HIVEService.h"
NSArray<NSString *> *targetLanguages = @[@"ko", @"ja", @"ar"];
HiveChatTranslateParams translateParams = [[HiveChatTranslateParams alloc] message: @"hello"
sourceLanguage: @"auto"
targetLanguages: targetLanguages];
[HiveChat translateWithParams: translateParams
handler:^(HIVEResultAPI * result, HiveChatTranslationData * data) {
if (result.isSuccess && data) {
// data is translate language messages
}
}];