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

ช่อง

การสร้างช่อง

ในการสร้างช่องสนทนาใหม่ ให้สร้างวัตถุ CreateChannelParams และจากนั้นเรียกใช้วิธี createChannel() ของคลาส Chat

สร้างพารามิเตอร์ช่อง

ชื่อฟิลด์ คำอธิบาย ประเภท จำเป็น
channelId รหัสช่อง
(ตัวอักษรภาษาอังกฤษ, ตัวเลข, และอักขระพิเศษบางตัว (-, ., _, ~, :) ที่อนุญาต, สูงสุด 100 ตัวอักษร)
สตริง ใช่
password รหัสผ่าน (จำเป็นเฉพาะสำหรับช่อง PRIVATE)
(สูงสุด 50 ตัวอักษร)
สตริง ไม่
channelName ชื่อช่อง
(สูงสุด 50 ตัวอักษร)
สตริง ใช่
maxMemberCount จำนวนผู้เข้าร่วมช่องสูงสุด
(ขั้นต่ำ 2 ถึงสูงสุด 5,000)
จำนวนเต็ม ใช่
type ประเภทช่อง (PRIVATE, PUBLIC, GROUP) enum ใช่
chatHistoryAllowed ว่าการดึงประวัติการแชทได้รับอนุญาตหรือไม่ enum ไม่

นี่คือตัวอย่างโค้ดในการสร้างช่องสนทนาใหม่

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
    }
}];

การลบช่องทาง

ในการลบช่องสนทนาที่มีอยู่แล้ว ให้เรียกใช้คลาส Chat เมธอด deleteChannel()

นี่คือตัวอย่างโค้ดสำหรับการลบช่องสนทนา

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

ป้อนพารามิเตอร์ช่อง

ชื่อฟิลด์ คำอธิบาย ประเภท จำเป็น
channelId รหัสช่อง string ใช่
password รหัสผ่าน (จำเป็นสำหรับช่อง PRIVATE) string ไม่

นี่คือตัวอย่างโค้ดสำหรับการเข้าช่องสนทนา

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

Note

หากคุณไม่ส่งผ่านวัตถุ GetChannelsParams (ส่ง null หากไม่มีวัตถุที่จัดเตรียมไว้) มันจะส่งคืนรายการทั้งหมดของช่องที่มีอยู่ในปัจจุบันโดยไม่มีการกรอง.

รับพารามิเตอร์ช่อง

ชื่อฟิลด์ คำอธิบาย ประเภท จำเป็น
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 จำนวนช่องที่ดึงต่อหน้า
(ขั้นต่ำ 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
memberCount จำนวนสมาชิกที่เข้าร่วมปัจจุบัน integer
maxMemberCount จำนวนผู้เข้าร่วมสูงสุดในช่อง integer
regTime วันที่และเวลาที่สร้างช่อง (ตาม UTC+0, รูปแบบ yyyy-MM-dd'T'HH:mm:ss.SSSZ) string
regTimeMillis วันที่และเวลาที่สร้างช่อง (Unix Timestamp) long
chatHistoryAllowed ว่าการดึงประวัติช่องได้รับอนุญาตหรือไม่ bool
query วิธีการดึงประวัติข้อความช่อง method

หน้าช่อง

ชื่อฟิลด์ คำอธิบาย ประเภท
ขนาด จำนวนรายการต่อหน้า จำนวนเต็ม
หน้าปัจจุบัน หมายเลขหน้าปัจจุบัน จำนวนเต็ม
จำนวนทั้งหมด จำนวนรายการทั้งหมด จำนวนเต็ม
จำนวนหน้าทั้งหมด จำนวนหน้าทั้งหมด จำนวนเต็ม

ต่อไปนี้คือตัวอย่างโค้ดเพื่อดึงรายการช่องประเภท 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
        }

        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

        for (Chat::Channel *channel : channels) {
            // Retrieve Channel
        }

        if (channelPage != null) {
            // Retrieve ChannelPage
        }
    }
}];

การดึงข้อมูลช่อง

ในการดึงข้อมูลรายละเอียดเกี่ยวกับช่องเฉพาะ ให้เรียกใช้เมธอด getChannelInfo() ของคลาส Chat

การตอบสนองรวมถึงวัตถุ Channel และวัตถุ Member และโครงสร้างมีดังนี้

ช่อง

ชื่อฟิลด์ คำอธิบาย ประเภท
channelId รหัสช่อง string
type ประเภทช่อง (PRIVATE, PUBLIC, GROUP) enum
owner เจ้าของช่อง Hive PlayerID 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

สมาชิก

ชื่อฟิลด์ คำอธิบาย ประเภท
playerId Hive PlayerID long
connectedTime เวลาการเชื่อมต่อ (ตาม UTC+0, รูปแบบ yyyy-MM-dd'T'HH:mm:ss.SSSZ) string
connectedTimeeMillis เวลาการเชื่อมต่อ (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

         (channel != nullptr) {
            // ดึงข้อมูล 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 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 {
        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
        }
    }
}];

การสอบถามสมาชิกช่อง

ในการดูสมาชิกผู้เข้าร่วมช่อง ให้เรียกใช้วิธี getChannelMembers() ของคลาส Chat

Note

ค่าที่ตอบกลับจะเหมือนกับวัตถุ 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 เท่านั้นที่สามารถดึงประวัติได้

พารามิเตอร์การสอบถามรายการข้อความช่อง

ชื่อฟิลด์ คำอธิบาย ประเภท จำเป็น
size ขนาดของข้อความที่จะได้รับ (ขั้นต่ำ 1 ~ สูงสุด 50) จำนวนเต็ม ใช่
index สตริงดัชนีที่จำเป็นสำหรับการค้นหาเพิ่มเติม ทิ้งว่างไว้สำหรับการค้นหาครั้งแรก สตริง ใช่

Channelmessagelistquerylistener

ชื่อฟิลด์ คำอธิบาย ประเภท
hasNext ธงที่บ่งบอกว่ามีการค้นหาเพิ่มเติมได้หรือไม่ long
nextIndex สตริงดัชนีที่จำเป็นสำหรับการค้นหาเพิ่มเติม string
content อาร์เรย์ของวัตถุ ChannelMessage ที่ดึงมา ChannelMessage
using hive;

ChannelMessageListQueryParams queryParams = new ChannelMessageListQueryParams(10, "");
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;
params.size = 10;
params.queryIndex = "";

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(size = 50)

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(50);

channel.query(queryParams, (result, response) -> {
    if (result.isSuccess() && response != null) {
        for (HiveChatChannelMessage message : response.getContent()) {
            // channel message list
        }
    }
});
import HIVEService

let queryParams = HiveChatParams.ChannelMessageListQueryParams(size: 10, index: "")

channel.query(queryParams) { result, response in
    if result.isSuccess(),
       let contents = response.content {
        for (let message in contents) {
            // channel message list
        }
    }
}
#import "HIVEService.h"

HiveChatChannelMessageListQueryParams *queryParams = [[HiveChatChannelMessageListQueryParams alloc] initWithSize:10 index:@""];

[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 setTranslationEnabled: translateEnabled handler:^(HIVEResultAPI * result) {
    if (result.isSuccess()) {
        // Channel Message Translate set completed.
    }
}];

การจัดการเหตุการณ์ช่อง

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