Table of Contents

私信聊天会话接口

预声明变量

readonly KookSocketClient _socketClient = null;
readonly KookRestClient _restClient = null;
readonly IKookClient _client = null;

获取私信聊天会话列表

GET /api/v3/user-chat/list

// 缓存获取私信聊天会话列表
IReadOnlyCollection<SocketDMChannel> cachedDmChannels = _socketClient.DMChannels;

// API 请求
IReadOnlyCollection<IDMChannel> dmChannels = await _client.GetDMChannelsAsync();

获取私信聊天会话详情

GET /api/v3/user-chat/view

Guid chatCode = default; // 要获取详情的私信聊天会话的 ChatCode
ulong userId = default; // 要获取详情的私信聊天会话的 UserId

// 缓存获取私信聊天会话详情
SocketDMChannel dmChannelByChatCode = _socketClient.GetDMChannel(chatCode);
SocketDMChannel dmChannelByUserId = _socketClient.GetDMChannel(userId);

// API 请求
IDMChannel dmChannel = await _client.GetDMChannelAsync(chatCode);

创建私信聊天会话

POST /api/v3/user-chat/create

IUser user = null; // 要创建私信聊天会话的用户

// API 请求
IDMChannel dmChannel = await user.CreateDMChannelAsync();

删除私信聊天会话

POST /api/v3/user-chat/delete

IDMChannel dmChannel = null; // 要删除的私信聊天会话

// API 请求
await dmChannel.CloseAsync()