ช่อง¶
การสร้างช่อง¶
ในการสร้างช่องสนทนาใหม่ ให้สร้างวัตถุ CreateChannelParams และจากนั้นเรียกใช้วิธี createChannel() ของคลาส Chat 
สร้างพารามิเตอร์ช่อง¶
| ชื่อฟิลด์ | คำอธิบาย | ประเภท | จำเป็น | 
|---|---|---|---|
| channelId | รหัสช่อง (ตัวอักษรภาษาอังกฤษ, ตัวเลข, และอักขระพิเศษบางตัว ( -,.,_,~,:) ได้รับอนุญาต, สูงสุด 100 ตัวอักษร) | string | Y | 
| password | รหัสผ่าน (ฟิลด์ที่จำเป็นเฉพาะสำหรับช่อง PRIVATE)(สูงสุด 50 ตัวอักษร) | string | N | 
| channelName | ชื่อช่อง (สูงสุด 50 ตัวอักษร) | string | Y | 
| maxMemberCount | จำนวนสูงสุดของผู้เข้าร่วมช่อง (ขั้นต่ำ 2 ถึงสูงสุด 5,000) | integer | Y | 
| type | ประเภทช่อง ( PRIVATE,PUBLIC,GROUP) | enum | Y | 
ต่อไปนี้คือตัวอย่างโค้ดสำหรับการสร้างช่องการสนทนาใหม่
#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 และจากนั้นเรียกใช้เมธอด enterChannel() ของคลาส Chat 
ป้อนพารามิเตอร์ช่อง¶
| ชื่อฟิลด์ | คำอธิบาย | ประเภท | จำเป็น | 
|---|---|---|---|
| channelId | รหัสช่อง | สตริง | ใช่ | 
| password | รหัสผ่าน (จำเป็นสำหรับช่อง PRIVATE) | สตริง | ไม่ | 
นี่คือตัวอย่างโค้ดสำหรับการเข้าสู่ช่องสนทนา
#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
    }
}));
ช่องทางออก¶
ในการออกจากช่องแชทที่คุณเข้าร่วม ให้เรียกใช้คลาส Chat เมธอด exitChannel() 
นี่คือตัวอย่างโค้ดสำหรับออกจากช่องสนทนาที่คุณเข้าร่วม
ดูรายการช่องทั้งหมด¶
ในการดึงรายชื่อช่องทั้งหมดที่มีอยู่ในปัจจุบัน ให้สร้างวัตถุ GetChannelsParams และจากนั้นเรียกใช้วิธี getChannels() ของคลาส Chat 
Note
หากคุณไม่ส่งผ่านวัตถุ GetChannelsParams (ส่ง null หากไม่มีวัตถุที่ให้ไว้) มันจะส่งคืนรายการทั้งหมดของช่องที่มีอยู่ในปัจจุบันโดยไม่กรอง
รับพารามิเตอร์ช่อง¶
| ชื่อฟิลด์ | คำอธิบาย | ประเภท | จำเป็น | 
|---|---|---|---|
| type | ประเภทช่อง ( PRIVATE,PUBLIC,GROUP) | enum | Y | 
| channelId | ดึงช่องที่เริ่มต้นด้วย ID ช่องเฉพาะ | string | N | 
| channelName | ดึงช่องที่มีชื่อช่องเฉพาะ | string | N | 
| pageOrder | ลำดับการจัดเรียง ( ASC,DESC)(ค่าเริ่มต้น DESC) | string | N | 
| pageSize | จำนวนช่องที่ดึงต่อหน้า (ขั้นต่ำ 10 ~ สูงสุด 100, ค่าเริ่มต้น 10) | integer | N | 
| pageNumber | หมายเลขหน้าที่จะดึง (เริ่มจาก 1, ค่าเริ่มต้น 1) | integer | N | 
วัตถุ Channel และวัตถุ ChannelPage จะถูกจัดเตรียมเป็นการตอบสนอง และโครงสร้างมีดังนี้
ช่อง¶
| ชื่อฟิลด์ | คำอธิบาย | ประเภท | 
|---|---|---|
| channelId | รหัสช่อง | string | 
| type | ประเภทช่อง ( PRIVATE,PUBLIC,GROUP) | enum | 
| owner | เจ้าของช่อง Hive PlayerID | string | 
| channelName | ชื่อช่อง | string | 
| maxMemberCount | จำนวนสูงสุดของผู้เข้าร่วมช่อง | integer | 
| regTime | วันที่และเวลาที่สร้างช่อง (ตาม UTC+0, รูปแบบ:yyyy-MM-dd'T'HH:mm:ss.SSSZ) | string | 
| regTimeMillis | วันที่และเวลาที่สร้างช่อง (Unix Timestamp) | long | 
ช่องทาง¶
| ชื่อฟิลด์ | คำอธิบาย | ประเภท | 
|---|---|---|
| ขนาด | จำนวนรายการต่อหน้า | จำนวนเต็ม | 
| หน้าปัจจุบัน | หมายเลขหน้าปัจจุบัน | จำนวนเต็ม | 
| จำนวนทั้งหมด | จำนวนรายการทั้งหมด | จำนวนเต็ม | 
| จำนวนหน้าทั้งหมด | จำนวนหน้าทั้งหมด | จำนวนเต็ม | 
ต่อไปนี้คือตัวอย่างโค้ดเพื่อดึงรายการช่องประเภท 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) {
            // ดึงข้อมูล 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
        สำหรับ (Chat::Channel channel : channels) {
            // ดึงช่อง
        }
        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
        }
        channelPage?.let {
            // 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
        สำหรับ (Chat::Channel *channel : channels) {
            // ดึงข้อมูลช่อง
        }
        if (channelPage != null) {
            // Retrieve ChannelPage
        }
    }
}];
การสอบถามข้อมูลช่อง¶
ในการดึงข้อมูลรายละเอียดเกี่ยวกับช่องเฉพาะ ให้เรียกใช้เมธอด getChannelInfo() ของคลาส Chat 
การตอบสนองรวมถึงวัตถุ Channel และวัตถุ Member และโครงสร้างมีดังนี้
ช่อง¶
| ชื่อฟิลด์ | คำอธิบาย | ประเภท | 
|---|---|---|
| channelId | รหัสช่อง | string | 
| type | ประเภทช่อง ( PRIVATE,PUBLIC,GROUP) | enum | 
| owner | เจ้าของช่อง Hive PlayerID | string | 
| channelName | ชื่อช่อง | string | 
| maxMemberCount | จำนวนสูงสุดของผู้เข้าร่วมช่อง | integer | 
| regTime | วันที่และเวลาที่สร้างช่อง (ตาม UTC+0, รูปแบบyyyy-MM-dd'T'HH:mm:ss.SSSZ) | string | 
| regTimeMillis | วันที่และเวลาที่สร้างช่อง (Unix Timestamp) | long | 
สมาชิก¶
| ชื่อฟิลด์ | คำอธิบาย | ประเภท | 
|---|---|---|
| playerId | Hive PlayerID | long | 
| connectedTime | เวลาเชื่อมต่อ (ตาม UTC+0, รูปแบบyyyy-MM-dd'T'HH:mm:ss.SSSZ) | string | 
| connectedTimeeMillis | เวลาเชื่อมต่อ (Unix Timestamp) | long | 
ต่อไปนี้คือตัวอย่างโค้ดในการดึงข้อมูลรายละเอียดเกี่ยวกับช่องเฉพาะ
#include "HiveChat.h"
FString ChannelId = TEXT("CHANNEL_ID");
FHiveChat::GetChannelInfo(ChannelId, FHiveChatOnGetChannelInfoDelegate::CreateLambda([this](const FHiveResultAPI& Result, const FHiveChannel& channel, the TArray<FHiveMember>& members) {
    if (Result.IsSuccess()) {
        // API Call Success
        if (channel != nullptr) {
            // Retrieve Channel
        }
        สำหรับ (const FHiveMember& Member : Members) {
            // ดึงข้อมูลสมาชิก
        }
    }
}));
#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
        }
        สำหรับ (Chat::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().
Note
ค่าที่ตอบกลับจะเหมือนกับวัตถุ 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
        }
    }
}));
การจัดการเหตุการณ์ช่อง¶
Hive ตรวจจับสถานะการเชื่อมต่อของเซิร์ฟเวอร์ซ็อกเก็ตแชทและส่งเหตุการณ์การเปลี่ยนแปลงสถานะที่เกิดขึ้นกับผู้ใช้แอปและช่องทางไปยังแอปอย่างต่อเนื่อง สำหรับวิธีการจัดการเหตุการณ์โดยละเอียด โปรดดูที่เอกสาร การจัดการเหตุการณ์ > เหตุการณ์ช่องทาง