跳转至

渠道

渠道创建

要创建一个新的对话频道,请创建一个 CreateChannelParams 对象,然后调用 Chat 类的 createChannel() 方法。

创建频道参数

字段名称 描述 类型 必需
channelId 渠道 ID
(允许英文字母、数字和某些特殊字符 (-, ., _, ~, :),最多 100 个字符)
字符串
password 密码(仅对 PRIVATE 渠道必需)
(最多 50 个字符)
字符串
channelName 渠道名称
(最多 50 个字符)
字符串
maxMemberCount 渠道参与者的最大数量
(最少 2 到最多 5,000)
整数
type 渠道类型 (PRIVATE, PUBLIC, GROUP) 枚举
chatHistoryAllowed 是否允许检索聊天记录 枚举

这是一个创建新对话频道的示例代码。

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 调用成功
        }
    }
})
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 调用成功
    }
}
#import "HIVEService.h"

HiveChatCreateChannelParams* params = [[HiveChatCreateChannelParams alloc] init];
params.channelId = @"CHANNEL_ID";
params.password = @"";
params.channelName = @"CHANNEL_NAME";
params.maxMemberCount = 8;
params.type = HiveChatChannelTypePublicChannel;

[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 对象,然后调用 Chat 类的 enterChannel() 方法。

输入通道参数

字段名称 描述 类型 必需
channelId 渠道ID 字符串
password 密码(PRIVATE 渠道所需) 字符串

这是进入对话频道的示例代码。

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 调用成功
    }
}];

渠道退出

要退出您参与的聊天频道,请调用Chat类的exitChannel()方法。

这是一个关于退出您参与的对话频道的示例代码。

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 调用成功
        }
    }
})
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 对象,然后调用 Chat 类的 getChannels() 方法。

Note

如果您不传递GetChannelsParams对象(如果没有提供对象则传递null),它将返回当前存在的所有频道的完整列表,而不进行过滤。

获取频道参数

字段名称 描述 类型 必需
type 渠道类型(PRIVATEPUBLICGROUP 枚举
channelId 检索以特定频道ID开头的频道 字符串
channelName 检索包含特定频道名称的频道 字符串
sort 渠道排序标准(ChannelIdChannelNameRegTime 枚举
pageOrder 排序方式(ASCDESC
(默认DESC
字符串
pageSize 每页检索的频道数量
(最小1 ~ 最大10,默认10)
整数
pageNumber 要检索的页码
(从1开始,默认1)
整数

Channel对象和ChannelPage对象作为响应提供,结构如下。

渠道

字段名称 描述 类型
channelId 渠道 ID 字符串
type 渠道类型 (PRIVATE, PUBLIC, GROUP) 枚举
owner 渠道所有者的 Hive 玩家 ID 字符串
channelName 渠道名称 字符串
memberCount 当前参与成员的数量 整数
maxMemberCount 渠道中最大参与者数量 整数
regTime 渠道创建日期和时间(基于 UTC+0,格式为 yyyy-MM-dd'T'HH:mm:ss.SSSZ 字符串
regTimeMillis 渠道创建日期和时间(Unix 时间戳) 长整型
chatHistoryAllowed 是否允许检索频道历史记录 布尔值
query 检索频道消息历史的方法 方法

渠道页面

字段名称 描述 类型
size 每页项目数量 整数
currentPage 当前页码 整数
totalElements 项目总数 整数
totalPages 页数总数 整数

以下是一个示例代码,用于检索所有现有的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调用成功

        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调用成功

        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 调用成功

            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 调用成功

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

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

渠道信息检索

要检索有关特定频道的详细信息,请调用Chat类的getChannelInfo()方法。

响应包括Channel对象和Member对象,结构如下。

渠道

字段名称 描述 类型
channelId 频道 ID 字符串
type 频道类型 (PRIVATE, PUBLIC, GROUP) 枚举
owner 频道所有者的 Hive PlayerID 字符串
channelName 频道名称 字符串
memberCount 当前参与成员的数量 整数
maxMemberCount 频道参与者的最大数量 整数
regTime 频道创建日期和时间(基于 UTC+0,格式为 yyyy-MM-dd'T'HH:mm:ss.SSSZ 字符串
regTimeMillis 频道创建日期和时间(Unix 时间戳) 长整型
chatHistoryAllowed 是否可以查询频道历史 布尔值
query 查询频道消息历史的方法 方法

会员

字段名称 描述 类型
playerId Hive 玩家ID long
connectedTime 连接时间(基于 UTC+0,格式 yyyy-MM-dd'T'HH:mm:ss.SSSZ string
connectedTimeeMillis 连接时间(Unix 时间戳) 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调用成功

        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 {
        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

响应值与从getChannelInfo()传递的Member对象相同。

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 的频道才能检索历史记录。

渠道消息列表查询参数

字段名称 描述 类型 必需
prevSize 要检索的前一条消息数量(最小 0 ~ 最大 50,默认 0) 整数
nextSize 要检索的下一条消息数量(最小 0 ~ 最大 50,默认 0) 整数
messageId 根据此消息 ID 检索消息。如果为 null,则从最新消息开始检索。 字符串
sort 默认排序按日期降序排列。您可以根据查询方向更改排序方向(DESCASC,默认 DESC)。 字符串

ChannelmessagelistqueryResponse

字段名称 描述 类型
hasNext 当前集合后是否还有更多消息可检索 boolean
nextMessageId 用于检索当前集合后更多消息的消息 ID string
hasPrev 当前集合前是否还有更多消息可检索 boolean
prevMessageId 用于检索当前集合前更多消息的消息 ID string
content 检索到的消息列表 list<ChannelMessage>
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 {
        for (let message in contents) {
            // 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 聊天套接字服务器检测连接状态,并持续将应用用户与频道之间发生的状态变化事件传递给应用。有关详细的事件处理方法,请参阅 事件管理 > 频道事件 文档。