채널¶
채널 생성¶
대화 채널을 생성하려면 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 채널에는 처음 생성할 때 참여한 두 계정만 입장할 수 있습니다.
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개 ~ 최대 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 | 한 페이지당 항목 수 | 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() 메서드를 호출하세요. 응답값은 getChannelInfo()에서 전달하는 Member 객체와 같습니다.
#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 or 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개와 이후 메시지 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 채팅 소켓 서버 연결 상태를 감지하고 앱 사용자와 채널에서 발생하는 상태 변경 이벤트를 앱에 지속적으로 전달합니다. 이벤트 처리 방법은 이벤트 관리 > 채널 이벤트를 참조하세요.