会话置顶
SDK 提供设置会话是否置顶接口,置顶的状态将会被同步到服务端,切换设备后置顶状态也会一并同步下来。
设置会话置顶
方法
int changeConversationTopStatus(
RCIMConversationType type,
string targetId,
string channelId,
bool top
)
参数说明
参数 | 类型 | 说明 |
---|---|---|
type | RCIMConversationType | 会话类型 |
targetId | string | 会话 ID |
channelId | string | 频道 ID,仅支持超级群使用,其他会话类型传 null 即可 |
top | bool | 是否置顶,true置顶,false,不置顶 |
代码示例
int code = engine.changeConversationTopStatus(
type,
targetId,
channelId,
top
);
返回值
返回值 | 描述 |
---|---|
int | 当次接口操作状态码,并不代表最终操作结果,状态码详细信息 |
回调方法
- onConversationTopStatusChanged
delegate void OnConversationTopStatusChangedDelegate(int code,
RCIMConversationType type,
string targetId,
string channelId,
bool top);
OnConversationTopStatusChangedDelegate onConversationTopStatusChanged;
参数说明
参数 | 类型 | 说明 |
---|---|---|
code | int | 接口回调的状态码,0 代表成功,非 0 代表出现异常 |
type | RCIMConversationType | 调用接口时传入的会话类型 |
targetId | string | 调用接口时传入的会话 ID |
channelId | string | 调用接口时传入的频道 ID |
top | bool | 置顶状态 |
代码示例
engine.onConversationTopStatusChanged = delegate(
int code,
RCIMConversationType type,
string targetId,
string channelId,
bool top
)
{
}
获取会话置顶状态
通过此方法获取指定会话的置顶状态。
方法
int loadConversationTopStatus(
RCIMConversationType type,
string targetId,
string channelId
)
参数说明
参数 | 类型 | 说明 |
---|---|---|
type | RCIMConversationType | 会话类型 |
targetId | string | 会话 ID |
channelId | string | 频道 ID,仅支持超级群使用,其他会话类型传 null 即可 |
代码示例
int code = engine.loadConversationTopStatus(
type,
targetId,
channelId
);
返回值
返回值 | 描述 |
---|---|
int | 当次接口操作状态码,并不代表最终操作结果,状态码详细信息 |
回调方法
- onConversationTopStatusLoaded
delegate void OnConversationTopStatusLoadedDelegate(int code,
RCIMConversationType type,
string targetId,
string channelId,
bool top);
OnConversationTopStatusLoadedDelegate onConversationTopStatusLoaded;
参数说明
参数 | 类型 | 说明 |
---|---|---|
code | int | 接口回调的状态码,0 代表成功,非 0 代表出现异常 |
type | RCIMConversationType | 调用接口时传入的会话类型 |
targetId | string | 调用接口时传入的会话 ID |
channelId | string | 调用接口时传入的频道 ID |
top | bool | 置顶状态 |
代码示例
engine.onConversationTopStatusLoaded = delegate(
int code,
RCIMConversationType type,
string targetId,
string channelId,
bool top
)
{
}
获取置顶会话列表
获取置顶会话列表
方法
int loadTopConversations(
List<RCIMConversationType> types,
string channelId
)
参数说明
参数 | 类型 | 说明 |
---|---|---|
types | RCIMConversationType | 会话类型 |
channelId | string | 频道 ID,仅支持超级群使用,其他会话类型传 null 即可 |
代码示例
int code = engine.loadTopConversations(
conversationTypesInt,
channelId,
);
返回值
返回值 | 描述 |
---|---|
int | 当次接口操作状态码,并不代表最终操作结果,状态码详细信息 |
回调方法
- onTopConversationsLoaded
delegate void OnTopConversationsLoadedDelegate(int code,
List<RCIMConversationType> types,
string channelId,
List<RCIMConversation> conversations);
OnTopConversationsLoadedDelegate onTopConversationsLoaded;
参数说明
参数 | 类型 | 说明 |
---|---|---|
code | int | 接口回调的状态码,0 代表成功,非 0 代表出现异常 |
types | List<[RCIMConversationType](https://www.rongcloud.cn/docs/api/unity/imlib_v5/latest/namespacecn__rongcloud__im__unity.html#a9d16c8fef2db0c4a5d6cfea2e5873aea)> | 调用接口时传入的会话类型列表 |
channelId | string | 调用接口时传入的频道 ID |
conversations | List<[RCIMConversation](https://www.rongcloud.cn/docs/api/unity/imlib_v5/latest/classcn__rongcloud__im__unity_1_1_r_c_i_m_conversation.html)> | 置顶的会话列表 |
代码示例
engine.onTopConversationsLoaded = delegate(
int code,
List<RCIMConversationType> types,
string channelId,
List<RCIMConversation> conversations
)
{
}
置顶状态同步
SDK 提供了会话状态(置顶或免打扰)同步机制,通过设置会话状态同步监听器,当在其它端修改会话状态时,可在本端实时监听到会话状态的改变。
方法
delegate void OnConversationTopStatusSyncedDelegate(
RCIMConversationType type,
string targetId,
string channelId,
bool top);
OnConversationTopStatusSyncedDelegate onConversationTopStatusSynced;
参数说明
参数 | 类型 | 说明 |
---|---|---|
type | RCIMConversationType | 会话类型 |
targetId | string | 会话ID |
channelId | string | 频道 ID |
top | bool | 是否置顶 |
代码示例
engine.onConversationTopStatusSynced = delegate(
RCIMConversationType type,
string targetId,
string channelId,
bool top
)
{
}