ข้ามไปที่เนื้อหา

แชนเนล

สร้างแชนเนล

หากต้องการสร้างแชนเนลแชท ให้สร้างออบเจ็กต์ CreateChannelParams แล้วเรียก createChannel() ของ Chat

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 และระบุ Player ID ของอีกฝ่ายใน otherPlayerId โดยไม่ส่ง 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 com.hive.Chat;

Chat.CreateChannelParams params = new Chat.CreateChannelParams(
    "CHANNEL_ID",
    "",
    "CHANNEL_NAME",
    8,
    Chat.ChannelType.PUBLIC
);

Chat.createChannel(params, result -> {
    if (result.isSuccess()) {
        // API Call Success
    }
});
import HIVEService

let params = Chat.CreateChannelParams(
    channelId: "CHANNEL_ID",
    password: "",
    channelName: "CHANNEL_NAME",
    maxMemberCount: 8,
    type: .public
)
ChatInterface.createChannel(params) { result in
    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
    }
}];

ลบแชนเนล

หากต้องการลบแชนเนลแชท ให้เรียก deleteChannel() ของ Chat

ตัวอย่างการลบแชนเนลแชท

using hive;

String channelId = "CHANNEL_ID";

Chat.deleteChannel(channelId, (ResultAPI result) => {
    if (result.isSuccess()) {
        // API Call Success
    }
});
#include "HiveChat.h"

FString ChannelId = TEXT("CHANNEL_ID");

FHiveChat::DeleteChannel(ChannelId, FHiveChatOnResultDelegate::CreateLambda([this](const FHiveResultAPI& Result) {
    if (Result.IsSuccess()) {
        // API Call Success
    }
}));
#include <HIVE_SDK_Plugin/HIVE_CPP.h>
using namespace hive;

std::string channelId = "CHANNEL_ID";

hat::deleteChannel(commonChannelId, [=](ResultAPI const & result) {
    if (result.isSuccess()) {
        // API Call Success
    }
});
import com.hive.Chat;
import com.hive.ResultAPI;

val channelId = "CHANNEL_ID"

Chat.deleteChannel(channelId, object: Chat.DeleteChannelListener{
    override fun onResult(result: ResultAPI) {
        if (result.isSuccess) {
            // API Call Success
        }
    }
})
import com.hive.Chat;

String channelId = "CHANNEL_ID";

Chat.deleteChannel(channelId, result -> {
    if (result.isSuccess()) {
        // API Call Success
    }
});
import HIVEService

let channelId = "CHANNEL_ID"
ChatInterface.deleteChannel(channelId: channelId) { result in
    if result.isSuccess() {
        // API Call Success
    }
}
#import "HIVEService.h"

NSString *channelId = @"CHANNEL_ID";
[HiveChat deleteChannelWithChannelId:channelId handler:^(HIVEResultAPI * result) {
    if ([result isSuccess]) {
        // API Call Success
    }
}];

เข้าแชนเนล

หากต้องการเข้าแชนเนลแชท ให้สร้างออบเจ็กต์ EnterChannelParams แล้วเรียก enterChannel() ของ Chat

เฉพาะสองบัญชีที่เข้าร่วมตอนสร้างแชนเนล ONE_ON_ONE เท่านั้นที่สามารถเข้าแชนเนลได้

EnterChannelParams

ชื่อฟิลด์ คำอธิบาย ชนิด จำเป็น
channelId ID แชนเนล string Y
password รหัสผ่าน (จำเป็นสำหรับแชนเนล PRIVATE) string N

ตัวอย่างการเข้าแชนเนลแชท

using hive;

EnterChannelParams enterChannelParams = new EnterChannelParams();
enterChannelParams.channelId = "CHANNEL_ID";
enterChannelParams.password = "";

Chat.enterChannel(enterChannelParams, (ResultAPI result) => {
    if (result.isSuccess()) {
        // API Call Success
    }
});
#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
    }
}));
#include <HIVE_SDK_Plugin/HIVE_CPP.h>
using namespace hive;

EnterChannelParams param;
param.channelId = "CHANNEL_ID";
param.password = "";

Chat::enterChannel(param, [=](ResultAPI const & result) {
    if (result.isSuccess()) {
        // API Call Success
    }
});
import com.hive.Chat;
import com.hive.ResultAPI;

val params = Chat.EnterChannelParams(
    channelId = "CHANNEL_ID",
    password = ""
)

Chat.enterChannel(params, object: Chat.EnterChannelListener{
    override fun onResult(result: ResultAPI) {
        if (result.isSuccess) {
            // API Call Success
        }
    }
})
import com.hive.Chat;

Chat.EnterChannelParams params = new Chat.EnterChannelParams(
    "CHANNEL_ID",
    ""
);

Chat.enterChannel(params, result -> {
    if (result.isSuccess()) {
        // API Call Success
    }
});
import HIVEService

let params = HiveChatParams.EnterChannelParams(
    channelId: "CHANNEL_ID",
    password: ""
)

ChatInterface.enterChannel(enterChannelParams: params) { result in
    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
    }
}];

ออกจากแชนเนล

หากต้องการออกจากแชนเนลแชทที่เข้าร่วม ให้เรียก exitChannel() ของ Chat

ตัวอย่างการออกจากแชนเนลแชทที่เข้าร่วม

using hive;

String channelId = "CHANNEL_ID";

Chat.exitChannel(channelId, (ResultAPI result) => {
    if (result.isSuccess()) {
        // API Call Success
    }
});
#include "HiveChat.h"

FString ChannelId = TEXT("CHANNEL_ID");

FHiveChat::ExitChannel(ChannelId, FHiveChatOnResultDelegate::CreateLambda([this](const FHiveResultAPI& Result) {
    if (Result.IsSuccess()) {
        // API Call Success
    }
}));
#include <HIVE_SDK_Plugin/HIVE_CPP.h>
using namespace hive;

std::string channelId = "CHANNEL_ID";

Chat::exitChannel(channelId, [=](ResultAPI const & result) {
    if (result.isSuccess()) {
        // API Call Success
    }
});
import com.hive.Chat;
import com.hive.ResultAPI;

val channelId = "CHANNEL_ID"

Chat.exitChannel(channelId, object: Chat.ExitChannelListener {
    override fun onResult(result: ResultAPI) {
        if (result.isSuccess) {
            // API Call Success
        }
    }
})
import com.hive.Chat;

String channelId = "CHANNEL_ID";

Chat.exitChannel(channelId, result -> {
    if (result.isSuccess()) {
        // API Call Success
    }
});
import HIVEService

let channelId = "CHANNEL_ID"
ChatInterface.exitChannel(channelId: channelId) { result in
    if result.isSuccess() {
        // API Call Success
    }
}
#import "HIVEService.h"

NSString *channelId = @"CHANNEL_ID";
[HiveChat exitChannelWithChannelId:channelId handler:^(HIVEResultAPI * result) {
    if ([result isSuccess]) {
        // API Call Success
    }
}];

เรียกดูรายการแชนเนลทั้งหมด

หากต้องการดูแชนเนลทั้งหมดที่มีอยู่ ให้สร้างออบเจ็กต์ GetChannelsParams แล้วเรียก getChannels() ของ Chat

การส่ง null แทนออบเจ็กต์ GetChannelsParams จะคืนค่าแชนเนลทั้งหมดที่มีอยู่โดยไม่กรอง

หากต้องการส่งข้อความถึงอีกฝ่ายในแชนเนล 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

ข้อควรทราบ

การส่ง null แทน GetChannelsParams จะคืนค่าแชนเนลทั้งหมดโดยไม่กรอง โดยรวมเฉพาะ 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
        }
    }
}];

เรียกดูข้อมูลแชนเนล

หากต้องการดูรายละเอียดแชนเนล ให้เรียก getChannelInfo() ของ Chat

การตอบกลับประกอบด้วยออบเจ็กต์ 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

ตัวอย่างการเรียกดูรายละเอียดแชนเนลที่ระบุ

using hive;

String channelId = "CHANNEL_ID";

Chat.getChannelInfo(channelId, (ResultAPI result, Channel channel, List<Member> members) => {
    if (result.isSuccess()) {
        if (channel != null) {
            // Retrieve Channel
        }

        foreach (Member member in members) {
            // Retrieve Member
        }
    }
});
#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 com.hive.Chat;

String channelId = "CHANNEL_ID";

Chat.getChannelInfo(channelId, (result, channel, members) -> {
    if(result.isSuccess()) {
        if (channel != null) {
            // Retrieve Channel
        }
        for (Chat.Member member : members) {
            // Retrieve Member
        }
    }
});
import HIVEService

let channelId = "CHANNEL_ID"
ChatInterface.getChannelInfo(channelId: channelId) { result, channel, members  in
    if result.isSuccess() {
        if let channel {
            // 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
        }
    }
}];

เรียกดูสมาชิกแชนเนล

หากต้องการดูสมาชิกแชนเนล ให้เรียก getChannelMembers() ของ Chat การตอบกลับใช้ออบเจ็กต์ Member แบบเดียวกับ getChannelInfo()

using hive;

String channelId = "CHANNEL_ID";

Chat.getChannelMembers(channelId, (ResultAPI result, List<Member> members) => {
    if (result.isSuccess()) {
        foreach (Member member in members) {
            // Retrieve 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
        }
    }
}));
#include <HIVE_SDK_Plugin/HIVE_CPP.h>
using namespace hive;

std::string channelId = "CHANNEL_ID";

Chat::getChannelMembers(channelId, [=](ResultAPI const & result, std::vector<Member> const & members) {
    if (result.isSuccess()) {
        for (Chat::Member member : members) {
            // Retrieve Member
        }
    }
});
import com.hive.Chat;
import com.hive.ResultAPI;

val channelId = "CHANNEL_ID"

Chat.getChannelMembers(channelId, object: Chat.GetChannelMembersListener{
    override fun onResult(result: ResultAPI, members: ArrayList<Chat.Member>) {
        if (result.isSuccess) {
            members.forEach {
                // Retrieve Member
            }
        }
    }
})
import com.hive.Chat;

String channelId = "CHANNEL_ID";

Chat.getChannelMembers(channelId, (result, members) -> {
    if (result.isSuccess()) {
        for (Chat.Member member : members) {
            // Retrieve Member
        }
    }
});
import HIVEService

let channelId = "CHANNEL_ID"
ChatInterface.getChannelMembers(channelId: channelId) { result, members in
    if result.isSuccess() {
        members.forEach {
            // Retrieve Member
        }
    }
}
#import "HIVEService.h"

NSString *channelId = @"CHANNEL_ID";
[HiveChat getChannelMembersWithChannelId:channelId handler:^(HIVEResultAPI * result, NSArray<HiveChatMember *> * members) {
    if ([result isSuccess]) {
        for (Chat::Member *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>

ตรวจสอบยอดรวมรีแอ็กชันจาก messageReaction ของแต่ละ ChannelMessage เมื่อเซิร์ฟเวอร์ย่อข้อมูล simplified จะเป็น true และรายการผู้ใช้แต่ละหมายเลข playerIds จะว่าง ซึ่งไม่ได้หมายความว่าไม่มีรีแอ็กชัน

หากต้องการรายละเอียดหรือตรวจสอบรีแอ็กชันของตนเอง โปรดดูเรียกดูรีแอ็กชันของข้อความในแชนเนล

ตัวอย่างการเรียกดูข้อความก่อนหน้าและถัดไปอย่างละ 10 ข้อความโดยอ้างอิง 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
        }
    }
}];

ตั้งค่าการรับคำแปลข้อความแชนเนลอัตโนมัติ

ตั้งค่าว่าจะรับคำแปลข้อความในแชนเนลอัตโนมัติหรือไม่ โดยตรวจสอบผลในออบเจ็กต์ ChannelMessage ที่ได้รับ

using hive;

bool translateEnabled = true;

channel.setTranslationEnabled(translateEnabled, (ResultAPI result) => {
    if(result.isSuccess()) {
        // Channel Message Translate set completed.
    }
});
#include <HIVE_SDK_Plugin/HIVE_CPP.h>
using namespace hive;

bool translateEnabled = true;

channel.setTranslationEnabled(translateEnabled, [=](ResultAPI const & result) {
    if(result.isSuccess()) {
        // Channel Message Translate set completed.
    }
});
import com.hive.Chat;
import com.hive.ResultAPI;

val translateEnabled = true;

channel.setTranslationEnabled(translateEnabled, object : Chat.SetTranslationEnabledListener {
    override fun onResult(result: ResultAPI) {
        if(result.isSuccess) {
            // Channel Message Translate set completed.
        }
    }
})
import com.hive.Chat;

boolean translateEnabled = true;

channel.setTransationEnabled(translateEnabled, (result) -> {
    if (result.isSuccess()) {
        // Channel Message Translate set completed.
    }
});
import HIVEService

let translateEnabled = true;

channel.setTranslationEnabled(translateEnabled) { result in
    if result.isSuccess() {
        // Channel Message Translate set completed.
    }
}
#import "HIVEService.h"

BOOL translateEnabled = YES;

[channel setTranslationEnabledWithEnabled: translateEnabled handler:^(HIVEResultAPI * result) {
    if ([result isSuccess]) {
        // Channel Message Translate set completed.
    }
}];

จัดการเหตุการณ์แชนเนล

Hive ตรวจจับสถานะการเชื่อมต่อเซิร์ฟเวอร์ซ็อกเก็ตแชทและส่งเหตุการณ์เปลี่ยนสถานะของผู้ใช้และแชนเนลไปยังแอปอย่างต่อเนื่อง ดูวิธีจัดการที่การจัดการเหตุการณ์ > เหตุการณ์แชนเนล