Channel¶
Channel creation¶
To create a chat channel, create a CreateChannelParams object and call createChannel() on Chat.
Createchannelparams¶
| Field Name | Description | Type | Required |
|---|---|---|---|
| channelId | Channel ID (English letters, numbers, and some special characters ( -, ., _, ~, :) allowed, up to 100 characters) | string | Y |
| password | Password (required only for PRIVATE channels)(up to 50 characters) | string | N |
| channelName | Channel name (up to 50 characters) | string | Y |
| maxMemberCount | Maximum number of channel participants (Minimum 2, maximum 5,000) (Required only for channels other than ONE_ON_ONE) | integer | N |
| type | Channel type (PRIVATE, PUBLIC, GROUP, ONE_ON_ONE) | enum | Y |
| chatHistoryAllowed | Whether chat history retrieval is allowed | boolean | N |
| otherPlayerId | Player ID of the user to invite (required only for ONE_ON_ONE) | long | N |
For a ONE_ON_ONE channel, set type to ONE_ON_ONE and enter the other user's Player ID in otherPlayerId. Do not pass maxMemberCount.
This example creates a chat channel.
using hive;
CreateChannelParams createChannelParams = new CreateChannelParams();
createChannelParams.channelId = "CHANNEL_ID";
createChannelParams.password = "";
createChannelParams.channelName = "CHANNEL_NAME";
createChannelParams.maxMemberCount = 8;
createChannelParams.type = ChannelType.PUBLIC;
if (result.isSuccess()) {
// API Call Success
}
});
#include "HiveChat.h"
FHiveCreateChannelParams CreateChannelParams = FHiveCreateChannelParams();
CreateChannelParams.ChannelId = TEXT("CHANNEL_ID");
CreateChannelParams.Password = TEXT("");
CreateChannelParams.ChannelName = TEXT("CHANNEL_NAME");
CreateChannelParams.MaxMemberCount = 8;
CreateChannelParams.Type = EHiveChannelType::Public;
FHiveChat::CreateChannel(CreateChannelParams, FHiveChatOnResultDelegate::CreateLambda([this](const FHiveResultAPI& Result) {
if (Result.IsSuccess()) {
// API Call Success
}
});
#include <HIVE_SDK_Plugin/HIVE_CPP.h>
using namespace hive;
CreateChannelParams param;
param.channelId = "CHANNEL_ID";
param.channelName = "CHANNEL_NAME";
param.password = "";
param.maxMemberCount = 8;
param.type = ChannelType::PUBLIC;
Chat::createChannel(param, [=](ResultAPI const & result) {
if (result.isSuccess()) {
// API Call Success
}
});
import com.hive.Chat;
import com.hive.ResultAPI;
val params = Chat.CreateChannelParams(
channelId = "CHANNEL_ID",
password = "",
channelName = "CHANNEL_NAME",
maxMemberCount = 8,
type = Chat.ChannelType.PUBLIC
)
Chat.createChannel(params, object: Chat.CreateChannelListener{
override fun onResult(result: ResultAPI) {
if (result.isSuccess) {
// API Call Success
}
}
})
#import "HIVEService.h"
HiveChatCreateChannelParams* params = [[HiveChatCreateChannelParams alloc] init];
params.channelId = @"CHANNEL_ID";
params.password = @"";
params.channelName = @"CHANNEL_NAME";
params.maxMemberCount = 8;
params.type = HiveChatChannelTypePublicChannel;
[HiveChat createChannelWithCreateParams:params handler:^(HIVEResultAPI * result) {
if ([result isSuccess]) {
// API Call Success
}
}];
Channel deletion¶
To delete a chat channel, call deleteChannel() on Chat.
This example deletes a chat channel.
Channel entry¶
To enter a chat channel, create an EnterChannelParams object and call enterChannel() on Chat.
Only the two accounts that participated when a ONE_ON_ONE channel was created can enter it.
Enterchannelparams¶
| Field Name | Description | Type | Required |
|---|---|---|---|
| channelId | Channel ID | string | Y |
| password | Password (required for PRIVATE channels) | string | N |
This example enters a chat channel.
#include "HiveChat.h"
FHiveEnterChannelParams EnterChannelParams = FHiveEnterChannelParams();
EnterChannelParams.ChannelId = TEXT("CHANNEL_ID");
EnterChannelParams.Password = TEXT("");
FHiveChat::EnterChannel(EnterChannelParams, FHiveChatOnResultDelegate::CreateLambda([this](const FHiveResultAPI& Result) {
if (Result.IsSuccess()) {
// API Call Success
}
}));
#import "HIVEService.h"
HiveChatEnterChannelParams* params = [[HiveChatEnterChannelParams alloc] init];
params.channelId = @"CHANNEL_ID";
params.password = @"";
[HiveChat enterChannelWithEnterChannelParams:params handler:^(HIVEResultAPI * result) {
if ([result isSuccess]) {
// API Call Success
}
}];
Channel exit¶
To leave a chat channel you have joined, call exitChannel() on Chat.
This example leaves a chat channel you have joined.
View all channel list¶
To retrieve all existing channels, create a GetChannelsParams object and call getChannels() on Chat.
Passing null instead of a GetChannelsParams object returns all existing channels without filtering.
To message another user in a ONE_ON_ONE channel without looking up the channel, call createChannel(). It accesses the existing channel or creates a new one.
Getchannelsparams¶
| Field Name | Description | Type | Required |
|---|---|---|---|
| type | Channel type to retrieve (PRIVATE, PUBLIC, GROUP) | enum | Y |
| channelId | Retrieve channels starting with a specific channel ID | string | N |
| channelName | Retrieve channels containing a specific channel name | string | N |
| sort | Channel sorting criteria (ChannelId, ChannelName, RegTime) | enum | N |
| pageOrder | Sorting method (ASC, DESC)(default DESC) | string | N |
| pageSize | Number of channels to retrieve per page (minimum 1 ~ maximum 10, default 10) | integer | N |
| pageNumber | Page number to retrieve (starts from 1, default 1) | integer | N |
The response contains Channel and ChannelPage objects. Their fields are listed below.
Channel¶
Information about the retrieved channel, including its ID, member count, and whether message history queries are allowed.
| Field Name | Description | Type |
|---|---|---|
| channelId | Channel ID | string |
| type | Channel type (PRIVATE, PUBLIC, GROUP) | enum |
| owner | Channel owner's Hive Player ID | string |
| channelName | Channel name | string |
| memberCount | Current number of participating members | integer |
| maxMemberCount | Maximum number of participants in the channel | integer |
| regTime | Channel creation date and time (based on UTC+0, format yyyy-MM-dd'T'HH:mm:ss.SSSZ) | string |
| regTimeMillis | Channel creation date and time (Unix Timestamp) | long |
| chatHistoryAllowed | Whether channel history retrieval is allowed | bool |
| query | Method for retrieving channel message history | method |
Channelpage¶
Pagination information for the channel list, including the current page and total number of pages.
| Field Name | Description | Type |
|---|---|---|
| size | Number of items per page | integer |
| currentPage | Current page number | integer |
| totalElements | Total number of items | integer |
| totalPages | Total number of pages | integer |
Notes¶
Passing null instead of a GetChannelsParams object returns all existing channels without filtering. Only PUBLIC, PRIVATE, and GROUP channels are included; ONE_ON_ONE channels are excluded.
Example code¶
This example retrieves all existing PUBLIC channels.
using hive;
GetChannelsParams getChannelsParams = new GetChannelsParams();
getChannelsParams.type = ChannelType.PUBLIC;
Chat.getChannels(getChannelsParams, (ResultAPI result, List<Channel> channels, ChannelPage channelPage) => {
if (result.isSuccess()) {
// API Call Success
foreach (Channel channel in channels) {
// Retrieve Channel
}
if (channelPage != null) {
// Retrieve ChannelPage
}
}
});
#include "HiveChat.h"
TOptional<FHiveGetChannelsParams> GetChannelsParams = FHiveGetChannelsParams();
GetChannelsParams->Type = EHiveChannelType::Public;
FHiveChat::GetChannels(GetChannelsParams, FHiveChatOnGetChannelsDelegate::CreateLambda([this](const FHiveResultAPI& Result, const TArray<FHiveChannel>& channels, FHiveChannelPage const & channelPage) {
if (Result.IsSuccess()) {
// API Call Success
for (const FHiveChannel& Channel : Channels) {
// Retrieve Channel
}
if (ChannelPage != nullptr) {
// Retrieve ChannelPage
}
}
}));
#include <HIVE_SDK_Plugin/HIVE_CPP.h>
using namespace hive;
Chat::GetChannelsParams params = Chat::GetChannelsParams();
params.type = Chat::ChannelType::PUBLIC;
Chat::getChannels(param, [=](ResultAPI const & result, std::vector<Channel> const & channels, ChannelPage const & pageInfo) {
if (result.isSuccess()) {
// API Call Success
for (Chat::Channel channel : channels) {
// Retrieve Channel
}
if (channelPage != null) {
// Retrieve ChannelPage
}
}
});
import com.hive.Chat;
import com.hive.ResultAPI;
val params = Chat.GetChannelsParams(type = Chat.ChannelType.PUBLIC)
Chat.getChannels(params, object: Chat.GetChannelsListener{
override fun onResult(
result: ResultAPI,
channels: ArrayList<Chat.Channel>,
channelPage: Chat.ChannelPage?
) {
if (result.isSuccess) {
// API Call Success
channels.forEach {
// Retrieve Channel
}
channelPage?.let {
// Retrieve ChannelPage
}
}
}
})
import com.hive.Chat;
Chat.GetChannelsParams params = new Chat.GetChannelsParams(Chat.ChannelType.PUBLIC, null, null, null, null, null);
Chat.getChannels(params, (result, channels, channelPage) -> {
if (result.isSuccess()) {
// API Call Success
for (Chat.Channel channel : channels) {
// Retrieve Channel
}
if (channelPage != null) {
// Retrieve ChannelPage
}
}
});
import HIVEService
let params = HiveChatParams.GetChannelsParams(type: .public, null, null, null, null, null)
ChatInterface.getChannels(getChannelsParams: params) { result, channels, pageInfo in
if result.isSuccess() {
channels.forEach {
// Retrieve Channel
}
if let pageInfo {
// Retrieve ChannelPage
}
}
}
#import "HIVEService.h"
HiveChatGetChannelsParams* params = [[HiveChatGetChannelsParams alloc] init];
params.type = Chat::ChannelType::PUBLIC;
[HiveChat getChannelsWithGetChannelsParams:params handler:^(HIVEResultAPI * result, NSArray<HiveChatChannelContent *> * channels, HiveChatPageInfo * pageInfo) {
if ([result isSuccess]) {
// API Call Success
for (Chat::Channel *channel : channels) {
// Retrieve Channel
}
if (pageInfo != pageInfo) {
// Retrieve ChannelPage
}
}
}];
Channel information retrieval¶
To retrieve details of a specific channel, call getChannelInfo() on Chat.
The response contains Channel and Member objects. Their fields are listed below.
Channel¶
Information about the retrieved channel, including its ID, member count, and whether message history queries are allowed.
| Field Name | Description | Type |
|---|---|---|
| channelId | Channel ID | string |
| type | Channel type (PRIVATE, PUBLIC, GROUP) | enum |
| owner | Channel owner's Hive Player ID | string |
| channelName | Channel name | string |
| memberCount | Current number of participating members | integer |
| maxMemberCount | Maximum number of channel participants | integer |
| regTime | Channel creation date and time (based on UTC+0, format yyyy-MM-dd'T'HH:mm:ss.SSSZ) | string |
| regTimeMillis | Channel creation date and time (Unix Timestamp) | long |
| chatHistoryAllowed | Whether channel history can be queried | bool |
| query | Method for querying channel message history | method |
Member¶
Information about a channel member, including the Player ID and connection time.
| Field Name | Description | Type |
|---|---|---|
| playerId | Hive Player ID | long |
| connectedTime | Connection time (based on UTC+0, format yyyy-MM-dd'T'HH:mm:ss.SSSZ) | string |
| connectedTimeMillis | Connection time (Unix Timestamp) | long |
| This example retrieves details of a specific channel. |
#include "HiveChat.h"
FString ChannelId = TEXT("CHANNEL_ID");
FHiveChat::GetChannelInfo(ChannelId, FHiveChatOnGetChannelInfoDelegate::CreateLambda([this](const FHiveResultAPI& Result, const FHiveChannel& channel, const TArray<FHiveMember>& members) {
if (Result.IsSuccess()) {
// API Call Success
if (channel != nullptr) {
// Retrieve Channel
}
for (const FHiveMember& Member : Members) {
// Retrieve Member
}
}
}));
#include <HIVE_SDK_Plugin/HIVE_CPP.h>
using namespace hive;
std::string channelId = "CHANNEL_ID";
Chat::getChannelInfo(channelId, [=](ResultAPI const & result, Channel const & channel, std::vector<Member> const & members) {
if (result.isSuccess()) {
if (channel != null) {
// Retrieve Channel
}
for (Chat::Member member : members) {
// Retrieve Member
}
}
});
import com.hive.Chat;
import com.hive.ResultAPI;
val channelId = "CHANNEL_ID"
Chat.getChannelInfo(channelId, object: Chat.GetChannelInfoListener {
override fun onResult(
result: ResultAPI,
channel: Chat.Channel?,
members: ArrayList<Chat.Member>
) {
if (result.isSuccess) {
channel?.let {
// Retrieve Channel
}
members.forEach {
// Retrieve Member
}
}
}
})
#import "HIVEService.h"
NSString *channelId = @"CHANNEL_ID";
[HiveChat getChannelInfoWithChannelId:channelId handler:^(HIVEResultAPI * result, HiveChatChannelContent * channel, NSArray<HiveChatMember *> * members) {
if ([result isSuccess]) {
if (channel != null) {
// Retrieve Channel
}
for (Chat::Member *member : members) {
// Retrieve Member
}
}
}];
Channel member inquiry¶
To retrieve channel members, call getChannelMembers() on Chat. The response uses the same Member object as getChannelInfo().
#include "HiveChat.h"
FString ChannelId = TEXT("CHANNEL_ID");
FHiveChat::GetChannelMembers(ChannelId, FHiveChatOnGetChannelMembersDelegate::CreateLambda([this](const FHiveResultAPI& Result, const TArray<FHiveMember>& members) {
if (Result.IsSuccess()) {
for (const FHiveMember& Member : members) {
// Retrieve Member
}
}
}));
Query channel message history¶
Call channel.query(ChannelMessageListQueryParams, ChannelMessageListQueryListener) to load previous chat messages.
You can query message history only for channels whose chatHistoryAllowed is true.
ChannelmessagelistqueryParams¶
| Field Name | Description | Type | Required |
|---|---|---|---|
| prevSize | Number of previous messages to retrieve (min 0 ~ max 50, default 0) | integer | N |
| nextSize | Number of next messages to retrieve (min 0 ~ max 50, default 0) | integer | N |
| messageId | Retrieves messages based on this message ID. If null, retrieves from the latest message. | string | N |
| sort | Default sorting is by date in descending order. You can change the sort direction depending on the query direction (DESC or ASC, default DESC). | string | N |
ChannelmessagelistqueryResponse¶
The message history query result contains messages and indicates whether more history is available before or after them.
| Field Name | Description | Type |
|---|---|---|
| hasNext | Whether there are more messages to retrieve after the current set | boolean |
| nextMessageId | Message ID to use as a reference for retrieving additional messages after | string |
| hasPrev | Whether there are more messages to retrieve before the current set | boolean |
| prevMessageId | Message ID to use as a reference for retrieving additional messages before | string |
| content | List of retrieved messages | list<ChannelMessage> |
Check messageReaction in each ChannelMessage for its reaction totals. When the server simplifies the totals, simplified is true and the per-index user lists, playerIds, are empty. An empty user list in this case does not mean there are no reactions.
For details or to check your own reaction, see Query channel message reactions.
This example retrieves 10 messages before and 10 messages after a specific message ID.
using hive;
ChannelMessageListQueryParams queryParams = new ChannelMessageListQueryParams();
queryParams.prevSize = 10;
queryParams.nextSize = 10;
queryParams.messageId = "TARGET_MESSAGE_ID";
channel.query(queryParams, (ResultAPI result, ChannelMessageListQueryResponse response) => {
if (result.isSuccess() && response != null) {
foreach (ChannelMessage message in response.content) {
// channel message list
}
}
});
#include <HIVE_SDK_Plugin/HIVE_CPP.h>
using namespace hive;
ChannelMessageListQueryParams queryParams;
queryParams.prevSize = 10;
queryParams.nextSize = 10;
queryParams.messageId = "TARGET_MESSAGE_ID";
channel.query(queryParams, [=](ResultAPI const & result, ChannelMessageListQueryResponse const & response) {
if (result.isSuccess()) {
for (auto message : response.message) {
// channel message list
}
}
});
import com.hive.Chat;
import com.hive.ResultAPI;
val queryParams = Chat.ChannelMessageListQueryParams(
prevSize = 10,
nextSize = 10,
messageId = "TARGET_MESSAGE_ID"
)
channel.query(queryParams, object : Chat.ChannelMessageListQueryListener {
override fun onResult(
result: ResultAPI,
response: Chat.ChannelMessageListQueryResponse?
) {
if(result.isSuccess && response != null) {
response.content.forEach {
// channel message list
}
}
}
})
import com.hive.Chat;
Chat.ChannelMessageListQueryParams queryParams = new Chat.ChannelMessageListQueryParams();
queryParams.prevSize = 10;
queryParams.nextSize = 10;
queryParams.messageId = "TARGET_MESSAGE_ID";
channel.query(queryParams, (result, response) -> {
if (result.isSuccess() && response != null) {
for (HiveChatChannelMessage message : response.getContent()) {
// channel message list
}
}
});
import HIVEService
let queryParams = HiveChatParams.ChannelMessageListQueryParams(prevSize: 10, nextSize: 10, messageId: "TARGET_MESSAGE_ID")
channel.query(queryParams) { result, response in
if result.isSuccess(),
let contents = response.content {
contents.forEach { message in
// channel message list
}
}
}
#import "HIVEService.h"
HiveChatChannelMessageListQueryParams* queryParams = [HiveChatChannelMessageListQueryParams new];
queryParams.prevSize = 10;
queryParams.nextSize = 10;
queryParams.messageId = @"TARGET_MESSAGE_ID";
[channel queryWithParams:queryParams listener:^(HIVEResultAPI * result, HiveChatChannelMessageListQueryResponse* response) {
if ([result isSuccess] && response.content) {
for (HiveChatChannelMessage *message in response.content) {
// channel message list
}
}
}];
Channel automatic translation reception settings¶
Set whether to receive automatic translations of channel messages. Check the translation in the received ChannelMessage object.
Channel event management¶
Hive detects the chat socket server connection status and continually delivers user and channel state changes to the app. See Event management > Channel events for event handling.