搜索消息
根据关键字搜索
根据关键字搜索指定会话中的消息
方法
C #
int searchMessages(
RCIMConversationType type,
string targetId,
string channelId,
string keyword,
int startTime,
int count
)
参数说明
| 参数 | 类型 | 说明 |
|---|---|---|
| type | RCIMConversationType | 会话类型 |
| targetId | string | 会话ID |
| channelId | string | 暂不支持该参数。传 null 即可 |
| keyword | string | 搜索的关键字 |
| startTime | int | 查询 beginTime 之前的消息, 传 0 时从最新消息开始搜索,从该时间往前搜索。 |
| count | int | 查询的数量,count 大于 0,小于等于 50。 |
返回值
| 返回值 | 描述 |
|---|---|
| int | 当次接口操作状态码,并不代表最终操作结果,状态码详细信息 |
代码示例
C #
int code = engine.searchMessages(
type,
targetId,
channelId,
keyword,
startTime,
count
);
回调方法
- onMessagesSearched 接口调用结果的监听
C #
delegate void OnMessagesSearchedDelegate(
int code,
RCIMConversationType type,
string targetId,
string channelId,
string keyword,
long startTime,
int count,
List<RCIMMessage> messages);
OnMessagesSearchedDelegate onMessagesSearched;
参数说明
| 参数名 | 参数类型 | 描述 |
|---|---|---|
| code | int | 接口回调的状态码,0 代表成功,非 0 代表出现异常 |
| type | RCIMConversationType | 调用接口时传入的会话类型 |
| targetId | string | 调用接口时传入的会话ID |
| channelId | string | 调用接口时传入的频道 ID |
| keyword | string | 调用接口时传入的关键字 |
| startTime | int | 调用接口时传入的时间戳 |
| count | int | 调用接口时传入的数量 |
| messages | List<RCIMMessage> | 查询到的消息集合 |
代码示例
C #
engine.onMessagesSearched = delegate(
int code,
RCIMConversationType type,
string targetId,
string channelId,
string keyword,
int startTime,
int count,
List<RCIMMessage> messages
)
{
};