チャンネル¶
チャンネルの作成¶
チャットチャンネルを作成するには、CreateChannelParamsオブジェクトを作成し、ChatのcreateChannel()を呼び出してください。
CreateChannelParams¶
| フィールド名 | 説明 | 型 | 必須 |
|---|---|---|---|
| channelId | チャンネルID (英大文字・小文字、数字、一部の特殊文字( -、.、_、~、:)を使用可能。最大100文字) | string | Y |
| password | パスワード(PRIVATEチャンネルのみ必須)(最大50文字) | string | N |
| channelName | チャンネル名 (最大50文字) | string | Y |
| maxMemberCount | チャンネルの最大参加人数 (最小2人~最大5,000人) ( ONE_ON_ONE以外のチャンネルのみ必須) | integer | N |
| type | チャンネルの種類(PRIVATE、PUBLIC、GROUP、ONE_ON_ONE) | enum | Y |
| chatHistoryAllowed | チャンネル履歴を取得できるか | boolean | N |
| otherPlayerId | 招待する相手のPlayer ID(ONE_ON_ONEのみ必須) | long | N |
ONE_ON_ONEチャンネルでは、typeをONE_ON_ONEに設定し、otherPlayerIdに相手のPlayer IDを指定してください。maxMemberCountは渡さないでください。
チャットチャンネルを作成する例です。
using hive;
CreateChannelParams createChannelParams = new CreateChannelParams();
createChannelParams.channelId = "CHANNEL_ID";
createChannelParams.password = "";
createChannelParams.channelName = "CHANNEL_NAME";
createChannelParams.maxMemberCount = 8;
createChannelParams.type = ChannelType.PUBLIC;
Chat.createChannel(createChannelParams, (ResultAPI result) => {
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 = Chat::ChannelType::PUBLIC;
[HiveChat createChannelWithCreateParams:params handler:^(HIVEResultAPI * result) {
if ([result isSuccess]) {
// API Call Success
}
}];
チャンネルの削除¶
チャットチャンネルを削除するには、ChatのdeleteChannel()を呼び出してください。
チャットチャンネルを削除する例です。
チャンネルへの入場¶
チャットチャンネルに入場するには、EnterChannelParamsオブジェクトを作成し、ChatのenterChannel()を呼び出してください。
ONE_ON_ONEチャンネルには、作成時に参加した2つのアカウントのみ入場できます。
EnterChannelParams¶
| フィールド名 | 説明 | 型 | 必須 |
|---|---|---|---|
| channelId | チャンネルID | string | Y |
| password | パスワード(PRIVATEチャンネルの場合は必須) | string | N |
チャットチャンネルに入場する例です。
#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
}
}];
チャンネルからの退場¶
参加中のチャットチャンネルから退場するには、ChatのexitChannel()を呼び出してください。
参加中のチャットチャンネルから退場する例です。
全チャンネル一覧の取得¶
現在存在する全チャンネルを取得するには、GetChannelsParamsオブジェクトを作成し、ChatのgetChannels()を呼び出してください。
GetChannelsParamsオブジェクトの代わりにnullを渡すと、現在存在する全チャンネルをフィルタリングせずに返します。
ONE_ON_ONEチャンネルを検索せずに相手にメッセージを送るには、createChannel()を呼び出してください。既存のチャンネルにアクセスするか、新しいチャンネルを作成します。
GetChannelsParams¶
| フィールド名 | 説明 | 型 | 必須 |
|---|---|---|---|
| type | 取得するチャンネルの種類(PRIVATE、PUBLIC、GROUP) | enum | Y |
| channelId | 指定したチャンネルIDで始まるチャンネルを取得 | string | N |
| channelName | 指定した文字列をチャンネル名に含むチャンネルを取得 | string | N |
| sort | チャンネルの並べ替え基準(ChannelId、ChannelName、RegTime) | enum | N |
| pageOrder | 並べ替え順序(ASC、DESC)(既定値: DESC) | string | N |
| pageSize | 1ページあたりの取得件数 (最小1件~最大10件、既定値:10) | integer | N |
| pageNumber | 取得するページ番号 (1から開始、既定値:1) | integer | N |
レスポンスにはChannelとChannelPageオブジェクトが含まれます。各フィールドは以下のとおりです。
Channel¶
取得したチャンネルの情報です。チャンネルID、参加人数、メッセージ履歴の取得可否を確認します。
| フィールド名 | 説明 | 型 |
|---|---|---|
| channelId | チャンネルID | string |
| type | チャンネルの種類(PRIVATE、PUBLIC、GROUP) | enum |
| owner | チャンネル所有者のHive Player ID | string |
| channelName | チャンネル名 | string |
| memberCount | 現在の参加メンバー数 | integer |
| maxMemberCount | チャンネルの最大参加人数 | integer |
| regTime | チャンネル作成日時(UTC+0、yyyy-MM-dd'T'HH:mm:ss.SSSZ形式) | string |
| regTimeMillis | チャンネル作成日時(Unix Timestamp) | long |
| chatHistoryAllowed | チャンネル履歴を取得できるか | bool |
| query | チャンネルメッセージ履歴の取得メソッド | method |
ChannelPage¶
チャンネル一覧のページ情報です。現在のページと総ページ数を確認します。
| フィールド名 | 説明 | 型 |
|---|---|---|
| size | 1ページあたりの項目数 | integer |
| currentPage | 現在のページ番号 | integer |
| totalElements | 総項目数 | integer |
| totalPages | 総ページ数 | integer |
注意事項¶
GetChannelsParamsオブジェクトの代わりにnullを渡すと、現在存在する全チャンネルをフィルタリングせずに返します。対象はPUBLIC、PRIVATE、GROUPで、ONE_ON_ONEは含みません。
コード例¶
現在存在するすべてのPUBLICチャンネルを取得する例です。
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 = HiveChatChannelTypePublicChannel;
[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
}
}
}];
チャンネル情報の取得¶
特定のチャンネルの詳細を取得するには、ChatのgetChannelInfo()を呼び出してください。
レスポンスにはChannelとMemberオブジェクトが含まれます。各フィールドは以下のとおりです。
Channel¶
取得したチャンネルの情報です。チャンネルID、参加人数、メッセージ履歴の取得可否を確認します。
| フィールド名 | 説明 | 型 |
|---|---|---|
| channelId | チャンネルID | string |
| type | チャンネルの種類(PRIVATE、PUBLIC、GROUP) | enum |
| owner | チャンネル所有者のHive Player ID | string |
| channelName | チャンネル名 | string |
| memberCount | 現在の参加メンバー数 | integer |
| maxMemberCount | チャンネルの最大参加人数 | integer |
| regTime | チャンネル作成日時(UTC+0、yyyy-MM-dd'T'HH:mm:ss.SSSZ形式) | string |
| regTimeMillis | チャンネル作成日時(Unix Timestamp) | long |
| chatHistoryAllowed | チャンネル履歴を取得できるか | bool |
| query | チャンネルメッセージ履歴の取得メソッド | method |
Member¶
チャンネルに参加しているメンバーの情報です。Player IDと接続日時を確認します。
| フィールド名 | 説明 | 型 |
|---|---|---|
| playerId | Hive Player ID | long |
| connectedTime | 接続日時(UTC+0、yyyy-MM-dd'T'HH:mm:ss.SSSZ形式) | string |
| connectedTimeMillis | 接続日時(Unix Timestamp) | long |
特定のチャンネルの詳細を取得する例です。
#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
}
}
}];
チャンネル参加メンバーの取得¶
チャンネルの参加メンバーを取得するには、ChatのgetChannelMembers()を呼び出してください。 返されるMemberオブジェクトは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
}
}
}));
チャンネルメッセージ履歴の取得¶
channel.query(ChannelMessageListQueryParams, ChannelMessageListQueryListener)を呼び出して過去のチャット履歴を読み込んでください。
chatHistoryAllowedがtrueのチャンネルのみメッセージ履歴を取得できます。
ChannelMessageListQueryParams¶
| フィールド名 | 説明 | 型 | 必須 |
|---|---|---|---|
| prevSize | 前のメッセージの取得件数(最小0件~最大50件、既定値:0) | integer | N |
| nextSize | 後のメッセージの取得件数(最小0件~最大50件、既定値:0) | integer | N |
| messageId | このメッセージIDを基準に履歴を取得します。nullの場合は最新のメッセージを基準に取得します。 | string | N |
| sort | 既定では日時の降順で並べ替えます。取得方向に応じて並べ替え順序を指定します(DESCまたはASC)。既定値:DESC | string | N |
ChannelMessageListQueryResponse¶
メッセージ履歴の取得結果です。取得したメッセージと、その前後に追加取得できる履歴があるかを確認します。
| フィールド名 | 説明 | 型 |
|---|---|---|
| hasNext | 後に追加取得できるメッセージがあるか | boolean |
| nextMessageId | 後のメッセージを追加取得する際に基準となるメッセージID | string |
| hasPrev | 前に追加取得できるメッセージがあるか | boolean |
| prevMessageId | 前のメッセージを追加取得する際に基準となるメッセージID | string |
| content | 取得したメッセージの結果 | list<ChannelMessage> |
取得した各ChannelMessageのmessageReactionでリアクションの集計を確認します。サーバーが集計を簡略化すると、simplifiedがtrueになり、番号ごとのユーザー一覧playerIdsは空になります。この場合、ユーザー一覧が空でもリアクションがないとは限りません。
詳細や自分のリアクションの登録状況は、チャンネルメッセージのリアクション取得を参照してください。
特定のメッセージIDを基準に前後10件ずつのメッセージを取得する例です。
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
}
}
}];
チャンネルメッセージの自動翻訳受信設定¶
チャンネルメッセージの自動翻訳を受信するか設定します。翻訳結果は受信したChannelMessageオブジェクトで確認してください。
チャンネルイベントの管理¶
Hiveはチャットソケットサーバーの接続状態を検知し、ユーザーとチャンネルの状態変更を継続的にアプリへ通知します。処理方法はイベント管理 > チャンネルイベントを参照してください。