删除云端会话列表
nim.deleteServerSessions({
sessions: [
{ scene: 'p2p', to: 'user1' },
{ scene: 'team', to: 'team123' }
],
done: function(err) {
if (err) {
console.log('删除云端会话失败', err)
} else {
console.log('删除云端会话成功')
}
}
})
要删除的会话 ID 的列表
查询某个云端会话
nim.getServerSession({
scene: 'p2p',
to: 'user1',
done: function(err, session) {
if (err) {
console.log('查询云端会话失败', err)
} else {
console.log('查询云端会话成功', session)
}
}
})
消息的场景
消息接收者
查询云端会话列表
nim.getServerSessions({
minTimestamp: 0,
maxTimestamp: Date.now(),
limit: 100,
needLastMsg: true,
done: function(err, data) {
if (err) {
console.log('查询云端会话列表失败', err)
} else {
console.log('查询云端会话列表成功', data.sessionList)
if (data.hasMore) {
console.log('还有更多会话')
}
}
}
})
分页大小,默认 100
最大的时间戳。与 minTimestamp 组成一个时间段作为查询条件。
默认当前时间戳
最小的时间戳。与 maxTimestamp 组成一个时间段作为查询条件。
默认 0 表示不限制。
是否需要返回 last msg。默认 true
是否下一页还有数据
会话列表
更新服务器上某个会话的扩展字段
nim.updateServerSession({
scene: 'p2p',
to: 'user1',
extra: JSON.stringify({ pinned: true }),
done: function(err) {
if (err) {
console.log('更新云端会话扩展失败', err)
} else {
console.log('更新云端会话扩展成功')
}
}
})
扩展字段,仅自己可见
消息的场景
消息接收者
云端会话服务 API 定义
注:SessionInterface 是本地会话,而 CloudSessionInterface 是远端会话。远端会话需要开通服务才能使用。