Message¶
Chat supports channel messages sent to a channel the user has joined and direct messages sent to a specific recipient.
Send channel messages¶
To send a message to a channel you have joined, create a ChannelSendMessageParams object and pass it to sendMessage() on Chat.
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¶
ChannelSendMessageParams specifies the channel, message content, reply target, and mentioned users.
| Field Name | Description | Type | Required |
|---|---|---|---|
| channelId | ID of the channel to send the message to | string | Y |
| message | Message to send to the channel (up to 200 characters) | string | Y |
| extraData | Additional channel message data Up to 256 bytes in UTF-8 | string | N |
| replyMessageId | Message ID being replied to | string | N |
| mentionedPlayerIds | Hive Player IDs of mentioned users | list <long> | N |
This example sends a basic message to a channel you have joined.
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`
}
}];
This example replies to a specific message in a channel you have 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`
}
}];
This example sends a message mentioning a user in a channel you have 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 Hive Player ID
playerIds.Add(5678); // User 2 Hive Player ID
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 Hive Player ID
PlayerIds.Add(5678); // User 2 Hive Player ID
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 Hive Player ID
playerIds.push_back(5678); // User 2 Hive Player ID
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) // Hive Player IDs of users 1 and 2
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 Hive Player ID
mentionedPlayerIds.add(5678L); // User 2 Hive Player ID
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] // Hive Player IDs of users 1 and 2
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)]; // User 1 Hive Player ID
[playerIds addObject:@(5678)]; // User 2 Hive Player ID
sendMessageParams.mentionedPlayerIds = playerIds;
[HiveChat sendMessageWithChannelSendMessageParams:sendMessageParams handler:^(HIVEResultAPI * result, HiveChatChannelSendMessageParams * retryParams) {
if (![result isSuccess]) {
// Message Send Failed. Try resending using `retryParams`
}
}];
Set and clear reactions on channel messages¶
A reaction expresses a user's response to a channel message. Set or clear it with setReaction() or clearReaction(), and use channel events to update the display.
Reactions use reactionIndex values from 1 to 200. Hive transmits only the index. Define the meaning of each index, such as an emoji or sticker, in your app.
Requirements for setting reactions¶
Users can react to messages in channels they have joined. Each user can leave one reaction per message. Notice messages do not support reactions.
Calling setReaction() with a different index replaces your existing reaction. Calling it with the same index keeps the reaction. clearReaction() clears your own reaction without requiring an index.
Handle results and events¶
Results from setReaction() and clearReaction() do not include reaction totals. Changes are delivered to all channel members, including the user who made the change, through onSetReaction and onClearReaction. Use these events to update reaction information on screen.
Replacing a reaction sends only onSetReaction with the new index, without onClearReaction. See Event management > Channel events.
Separate Like and reaction totals¶
Reactions and Likes maintain separate totals. If both features are used, a message has both totals, so display them separately in the app.
Set and clear example¶
This example sets and clears a reaction on a message in a channel you have joined.
using hive;
String messageId = "TARGET_MESSAGE_ID";
int reactionIndex = 5; // Game-defined reaction index (1–200)
// Set a reaction (replace any existing reaction)
channel.setReaction(messageId, reactionIndex, (ResultAPI result) => {
if (result.isSuccess()) {
// API Call Success
}
});
// Clear your reaction
channel.clearReaction(messageId, (ResultAPI result) => {
if (result.isSuccess()) {
// API Call Success
}
});
#include "HiveChat.h"
FString MessageId = TEXT("TARGET_MESSAGE_ID");
int32 ReactionIndex = 5; // Game-defined reaction index (1–200)
// Set a reaction (replace any existing reaction)
channel.SetReaction(MessageId, ReactionIndex, FHiveChannelSetReactionDelegate([this](const FHiveResultAPI& Result) {
if (Result.IsSuccess()) {
// API Call Success
}
}));
// Clear your reaction
channel.ClearReaction(MessageId, FHiveChannelClearReactionDelegate([this](const FHiveResultAPI& Result) {
if (Result.IsSuccess()) {
// API Call Success
}
}));
#include <HIVE_SDK_Plugin/HIVE_CPP.h>
using namespace hive;
std::string messageId = "TARGET_MESSAGE_ID";
int reactionIndex = 5; // Game-defined reaction index (1–200)
// Set a reaction (replace any existing reaction)
channel.setReaction(messageId, reactionIndex, [=](ResultAPI const & result) {
if (result.isSuccess()) {
// API Call Success
}
});
// Clear your reaction
channel.clearReaction(messageId, [=](ResultAPI const & result) {
if (result.isSuccess()) {
// API Call Success
}
});
import com.hive.Chat
import com.hive.ResultAPI
val messageId = "TARGET_MESSAGE_ID"
val reactionIndex = 5 // Game-defined reaction index (1–200)
// Set a reaction (replace any existing reaction)
channel.setReaction(messageId, reactionIndex, object: Chat.ReactionResultListener {
override fun onResult(result: ResultAPI, reactionIndex: Int) {
if (result.isSuccess) {
// API Call Success
}
}
})
// Clear your reaction
channel.clearReaction(messageId, object: Chat.ReactionResultListener {
override fun onResult(result: ResultAPI, reactionIndex: Int) {
if (result.isSuccess) {
// API Call Success
}
}
})
import com.hive.Chat;
import com.hive.ResultAPI;
String messageId = "TARGET_MESSAGE_ID";
int reactionIndex = 5; // Game-defined reaction index (1–200)
// Set a reaction (replace any existing reaction)
channel.setReaction(messageId, reactionIndex, new Chat.ReactionResultListener() {
@Override
public void onResult(@NonNull ResultAPI result, int reactionIndex) {
if (result.isSuccess()) {
// API Call Success
}
}
});
// Clear your reaction
channel.clearReaction(messageId, new Chat.ReactionResultListener() {
@Override
public void onResult(@NonNull ResultAPI result, int reactionIndex) {
if (result.isSuccess()) {
// API Call Success
}
}
});
import HIVEService
let messageId = "TARGET_MESSAGE_ID"
let reactionIndex = 5 // Game-defined reaction index (1–200)
// Set a reaction (replace any existing reaction)
channel.setReaction(messageId: messageId, reactionIndex: reactionIndex) { result in
if result.isSuccess() {
// API Call Success
}
}
// Clear your reaction
channel.clearReaction(messageId: messageId) { result in
if result.isSuccess() {
// API Call Success
}
}
#import "HIVEService.h"
NSString *messageId = @"TARGET_MESSAGE_ID";
NSInteger reactionIndex = 5; // Game-defined reaction index (1–200)
// Set a reaction (replace any existing reaction)
[channel setReactionWithMessageId:messageId reactionIndex:reactionIndex listener:^(HIVEResultAPI *result) {
if ([result isSuccess]) {
// API Call Success
}
}];
// Clear your reaction
[channel clearReactionWithMessageId:messageId listener:^(HIVEResultAPI *result) {
if ([result isSuccess]) {
// API Call Success
}
}];
Query channel message reactions¶
Check messageReaction in each ChannelMessage returned by a channel message history query. The server may simplify totals when a message has many reactions, so query details or your own reaction separately.
Simplified totals have simplified set to true and empty per-index Hive Player ID lists (playerIds). The overall totalCount and per-index count are still provided.
Choose a query method¶
Call getReactions() to retrieve all reactions grouped by index. It returns MessageReaction with Hive Player ID lists; simplified is always false.
Call getMyReaction() to retrieve only the logged-in user's reaction as PlayerReaction. Use it after reconnecting or when simplified history totals hide your reaction. It cannot retrieve another user's reaction.
MessageReaction¶
The complete reaction totals for a message. Use reactions for per-index totals and preserve the list order returned by the server.
| Field | Description | Type | Values and conditions |
|---|---|---|---|
| simplified | Whether totals are simplified | boolean | If true, omits each index's playerIds and provides only count |
| totalCount | Total reactions on the message | integer | Number of users who reacted |
| reactions | Totals grouped by reaction index | list<ReactionSummary> | Most recently added reaction index first |
ReactionSummary¶
The user count and Hive Player ID list for a reaction index. Each item in MessageReaction.reactions has this structure.
| Field | Description | Type | Values and conditions |
|---|---|---|---|
| reactionIndex | Reaction index | integer | 1–200 |
| count | Number of users with this reaction | integer | For this reaction index |
| playerIds | Hive Player IDs of users with this reaction | list<long> | Empty if simplified is true |
PlayerReaction¶
Indicates whether the logged-in user has reacted to a message. Check reacted before using reactionIndex.
| Field | Description | Type | Values and conditions |
|---|---|---|---|
| messageId | Message ID | string | The queried message |
| playerId | Hive Player ID | long | The logged-in user |
| reacted | Whether a reaction is registered | boolean | Whether you have reacted |
| reactionIndex | Registered reaction index | integer | 1–200 if registered; otherwise not a valid index |
Query reactions example¶
This example retrieves all reactions and your own reaction for a specific message.
using hive;
String messageId = "TARGET_MESSAGE_ID";
// Query all reactions on the message
channel.getReactions(messageId, (ResultAPI result, MessageReaction messageReaction) => {
if (result.isSuccess() && messageReaction != null) {
foreach (ReactionSummary summary in messageReaction.reactions) {
// summary.reactionIndex, summary.count, summary.playerIds
}
}
});
// Query your own reaction
channel.getMyReaction(messageId, (ResultAPI result, PlayerReaction playerReaction) => {
if (result.isSuccess() && playerReaction != null && playerReaction.reacted) {
// playerReaction.reactionIndex
}
});
#include "HiveChat.h"
FString MessageId = TEXT("TARGET_MESSAGE_ID");
// Query all reactions on the message
channel.GetReactions(MessageId, FHiveChannelGetReactionsDelegate([this](const FHiveResultAPI& Result, const FHiveMessageReaction& MessageReaction) {
if (Result.IsSuccess()) {
for (const FHiveReactionSummary& Summary : MessageReaction.reactions) {
// Summary.reactionIndex, Summary.count, Summary.playerIds
}
}
}));
// Query your own reaction
channel.GetMyReaction(MessageId, FHiveChannelGetMyReactionDelegate([this](const FHiveResultAPI& Result, const FHivePlayerReaction& PlayerReaction) {
if (Result.IsSuccess() && PlayerReaction.reacted) {
// PlayerReaction.reactionIndex
}
}));
#include <HIVE_SDK_Plugin/HIVE_CPP.h>
using namespace hive;
std::string messageId = "TARGET_MESSAGE_ID";
// Query all reactions on the message
channel.getReactions(messageId, [=](ResultAPI const & result, MessageReaction const & messageReaction) {
if (result.isSuccess()) {
for (auto const & summary : messageReaction.reactions) {
// summary.reactionIndex, summary.count, summary.playerIds
}
}
});
// Query your own reaction
channel.getMyReaction(messageId, [=](ResultAPI const & result, PlayerReaction const & playerReaction) {
if (result.isSuccess() && playerReaction.reacted) {
// playerReaction.reactionIndex
}
});
import com.hive.Chat
import com.hive.ResultAPI
val messageId = "TARGET_MESSAGE_ID"
// Query all reactions on the message
channel.getReactions(messageId, object: Chat.GetReactionsListener {
override fun onResult(result: ResultAPI, messageId: String, messageReaction: Chat.MessageReaction?) {
if (result.isSuccess && messageReaction != null) {
messageReaction.reactions.forEach { entry ->
// entry.reactionIndex, entry.count, entry.playerIds
}
}
}
})
// Query your own reaction
channel.getMyReaction(messageId, object: Chat.GetMyReactionListener {
override fun onResult(result: ResultAPI, playerReaction: Chat.PlayerReaction?) {
if (result.isSuccess && playerReaction?.reacted == true) {
// playerReaction.reactionIndex
}
}
})
import com.hive.Chat;
import com.hive.ResultAPI;
String messageId = "TARGET_MESSAGE_ID";
// Query all reactions on the message
channel.getReactions(messageId, new Chat.GetReactionsListener() {
@Override
public void onResult(@NonNull ResultAPI result, @NonNull String messageId, Chat.MessageReaction messageReaction) {
if (result.isSuccess() && messageReaction != null) {
for (Chat.ReactionSummary entry : messageReaction.getReactions()) {
// entry.getReactionIndex(), entry.getCount(), entry.getPlayerIds()
}
}
}
});
// Query your own reaction
channel.getMyReaction(messageId, new Chat.GetMyReactionListener() {
@Override
public void onResult(@NonNull ResultAPI result, Chat.PlayerReaction playerReaction) {
if (result.isSuccess() && playerReaction != null && playerReaction.getReacted()) {
// playerReaction.getReactionIndex()
}
}
});
import HIVEService
let messageId = "TARGET_MESSAGE_ID"
// Query all reactions on the message
channel.getReactions(messageId: messageId) { result, reaction in
if result.isSuccess(), let reaction {
reaction.reactions.forEach { summary in
// summary.reactionIndex, summary.count, summary.playerIds
}
}
}
// Query your own reaction
channel.getMyReaction(messageId: messageId) { result, reaction in
if result.isSuccess(), let reaction, reaction.reacted {
// reaction.reactionIndex
}
}
#import "HIVEService.h"
NSString *messageId = @"TARGET_MESSAGE_ID";
// Query all reactions on the message
[channel getReactionsWithMessageId:messageId listener:^(HIVEResultAPI *result, HiveChatMessageReaction *reaction) {
if ([result isSuccess] && reaction) {
for (HiveChatReactionSummary *summary in reaction.reactions) {
// summary.reactionIndex, summary.count, summary.playerIds
}
}
}];
// Query your own reaction
[channel getMyReactionWithMessageId:messageId listener:^(HIVEResultAPI *result, HiveChatPlayerReaction *reaction) {
if ([result isSuccess] && reaction.reacted) {
// reaction.reactionIndex
}
}];
Add and remove Likes on channel messages¶
addReaction() and removeReaction() add or remove Likes on messages in channels you have joined. These Like-only methods use ReactionType.Like and are deprecated.
For new reactions, use setReaction() and clearReaction() as described in Set and clear reactions.
This example adds and removes Likes on messages in a channel you have 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¶
Receive sent messages through onChannelMessage in the addChannelListener event handler. See Event management > Channel events.
Direct message sending¶
To send a direct message, create a DirectSendMessageParams object and pass it to sendMessage() on Chat.
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¶
DirectSendMessageParams specifies the recipient and message content.
| Field Name | Description | Type | Required |
|---|---|---|---|
| toPlayerId | Recipient's Hive Player ID | long | Y |
| message | Message to send to the recipient (up to 200 characters) | string | Y |
| extraData | Additional direct message data Up to 256 bytes in UTF-8 | string | N |
This example sends a message directly 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`
}
}];
Direct message event management¶
Receive direct messages through onDirectMessage in the addUserListener event handler. See Event management > User events.
Message translation request¶
Attempting to request a translation for the message. The language code is based on ISO 639 alpha-2 standards.
Translateparams¶
TranslateParams specifies the message, source language, and target languages.
| Field Name | Description | Type | Required |
|---|---|---|---|
| message | Message | string | Y |
| sourceLanguage | Message language code. If omitted, auto detects the language. | string | N |
| targetLanguages | Array of target language codes | 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
}
}];
Report a channel message¶
To report a message, create a ReportMessageParams object and pass it to reportMessage() on Chat.
ReportMessageParams¶
ReportMessageParams specifies the message to report, its author, and the reason.
| Field name | Description | Type | Required |
|---|---|---|---|
| channelId | ID of the channel that contains the message to report | string | Y |
| messageId | ID of the message to report | string | Y |
| reporteePlayerId | Hive Player ID of the author of the reported message | long | Y |
| reasonType | Reason for reporting (INSULT, FRAUD, SPAM, ETC) | enum | Y |
| reasonDetail | Detailed reason for the report (enter this when reasonType is ETC; otherwise use null or omit it) | string | N |
Basic report request example¶
Use the following call when reporting a message for abusive language.
using hive;
ReportMessageParams reportMessageParams = new ReportMessageParams();
reportMessageParams.channelId = "abc";
reportMessageParams.messageId = "x8LIIIDbuVentUdL";
reportMessageParams.reporteePlayerId = 12345678;
reportMessageParams.reasonType = ReasonType.INSULT;
Chat.reportMessage(reportMessageParams, (ResultAPI result) => {
if (result.isSuccess()) {
// API call succeeded
}
});
#include <HIVE_SDK_Plugin/HIVE_CPP.h>
using namespace hive;
ReportMessageParams reportMessageParams;
reportMessageParams.channelId = "abc";
reportMessageParams.messageId = "x8LIIIDbuVentUdL";
reportMessageParams.reporteePlayerId = 12345678;
reportMessageParams.reasonType = ReasonType.INSULT;
Chat::reportMessage(params, [=](ResultAPI const & result) {
if (result.isSuccess()) {
// API call succeeded
}
});
val params = Chat.ReportMessageParam(
channelId = "abc",
messageId = "x8LIIIDbuVentUdL",
reporteePlayerId = 12345678,
reasonType = ReasonType.INSULT,
reasonDetail = null
)
Chat.reportMessage(params, object : Chat.ReportMessageListener {
override fun onResult(result: ResultAPI) {
if(result.isSuccess) {
// API call succeeded
}
}
})
#import "HIVEService.h"
HiveChatReportMessageParams* reportMessageParams = [[HiveChatReportMessageParams alloc] init];
reportMessageParams.channelId = "abc";
reportMessageParams.messageId = "x8LIIIDbuVentUdL";
reportMessageParams.reporteePlayerId = 12345678;
reportMessageParams.reasonType = ReasonType.INSULT;
[HiveChat reportMessageWithReportMessageParams:reportMessageParams handler:^(HIVEResultAPI * result) {
if ([result isSuccess]) {
// API call succeeded
}
}];
Report for other reasons¶
When you select Other (reasonType is ETC) as the reason for reporting a message, also enter a detailed reason (reasonDetail). If you select a predefined report reason, you can leave the detailed reason empty or omit it.