-
Notifications
You must be signed in to change notification settings - Fork 2
nim.session.NIMSession
nim/session.NIMSession
-
EventEmitter
<NIMSessionEvents
>↳
NIMSession
- eventNames
- listeners
- listenerCount
- emit
- on
- addListener
- once
- removeListener
- off
- removeAllListeners
- initEventHandlers
- queryStickTopSessionList
- setToStickTopSession
- updateToStickTopSession
- cancelToStickTopSession
- queryLastFewSessionAsync
- queryAllRecentSessionAsync
- deleteRecentSession
- deleteAllRecentSession
- deleteSessionRoamingMessage
- setUnreadCountZeroAsync
- setMultiUnreadCountZeroAsync
- setSessionTop
- setSessionExtendData
- setAllUnreadCountZeroAsync
- querySessionDataById
- queryHasmoreRoammsg
- queryAllHasmoreRoammsg
- updateHasmoreRoammsg
- deleteHasmoreRoammsg
▸ eventNames(): keyof NIMSessionEvents
[]
Return an array listing the events for which the emitter has registered listeners.
keyof NIMSessionEvents
[]
EventEmitter.eventNames
▸ listeners<T
>(event
): (...args
: ArgumentMap
<NIMSessionEvents
>[Extract
<T
, keyof NIMSessionEvents
>]) => void
[]
Return the listeners registered for a given event.
Name | Type |
---|---|
T |
extends keyof NIMSessionEvents
|
Name | Type |
---|---|
event |
T |
(...args
: ArgumentMap
<NIMSessionEvents
>[Extract
<T
, keyof NIMSessionEvents
>]) => void
[]
EventEmitter.listeners
▸ listenerCount(event
): number
Return the number of listeners listening to a given event.
Name | Type |
---|---|
event |
keyof NIMSessionEvents
|
number
EventEmitter.listenerCount
▸ emit<T
>(event
, ...args
): boolean
Calls each of the listeners registered for a given event.
Name | Type |
---|---|
T |
extends keyof NIMSessionEvents
|
Name | Type |
---|---|
event |
T |
...args |
ArgumentMap <NIMSessionEvents >[Extract <T , keyof NIMSessionEvents >] |
boolean
EventEmitter.emit
▸ on<T
>(event
, fn
, context?
): NIMSession
Add a listener for a given event.
Name | Type |
---|---|
T |
extends keyof NIMSessionEvents
|
Name | Type |
---|---|
event |
T |
fn |
(...args : ArgumentMap <NIMSessionEvents >[Extract <T , keyof NIMSessionEvents >]) => void
|
context? |
any |
EventEmitter.on
▸ addListener<T
>(event
, fn
, context?
): NIMSession
Name | Type |
---|---|
T |
extends keyof NIMSessionEvents
|
Name | Type |
---|---|
event |
T |
fn |
(...args : ArgumentMap <NIMSessionEvents >[Extract <T , keyof NIMSessionEvents >]) => void
|
context? |
any |
EventEmitter.addListener
▸ once<T
>(event
, fn
, context?
): NIMSession
Add a one-time listener for a given event.
Name | Type |
---|---|
T |
extends keyof NIMSessionEvents
|
Name | Type |
---|---|
event |
T |
fn |
(...args : ArgumentMap <NIMSessionEvents >[Extract <T , keyof NIMSessionEvents >]) => void
|
context? |
any |
EventEmitter.once
▸ removeListener<T
>(event
, fn?
, context?
, once?
): NIMSession
Remove the listeners of a given event.
Name | Type |
---|---|
T |
extends keyof NIMSessionEvents
|
Name | Type |
---|---|
event |
T |
fn? |
(...args : ArgumentMap <NIMSessionEvents >[Extract <T , keyof NIMSessionEvents >]) => void
|
context? |
any |
once? |
boolean |
EventEmitter.removeListener
▸ off<T
>(event
, fn?
, context?
, once?
): NIMSession
Name | Type |
---|---|
T |
extends keyof NIMSessionEvents
|
Name | Type |
---|---|
event |
T |
fn? |
(...args : ArgumentMap <NIMSessionEvents >[Extract <T , keyof NIMSessionEvents >]) => void
|
context? |
any |
once? |
boolean |
EventEmitter.off
▸ removeAllListeners(event?
): NIMSession
Remove all listeners, or those of the specified event.
Name | Type |
---|---|
event? |
keyof NIMSessionEvents
|
EventEmitter.removeAllListeners
▸ initEventHandlers(): void
注册全局回调
void
▸ queryStickTopSessionList(cb
): Promise
<[NIMResCode
, string
]>
查询置顶会话列表
Note
200:成功
Name | Type | Description |
---|---|---|
cb |
QueryStickTopSessionListCallback |
置顶会话列表查询结果的回调函数 |
Promise
<[NIMResCode
, string
]>
void 无返回值
▸ setToStickTopSession(session_id
, to_type
, ext
, cb
): Promise
<[NIMResCode
, string
]>
设置置顶会话
Note
200:成功
Name | Type | Description |
---|---|---|
session_id |
string |
会话id |
to_type |
number |
会话类型 |
ext |
string |
扩展字段 |
cb |
SetToStickTopSessionCallback |
置顶会话设置结果的回调函数 |
Promise
<[NIMResCode
, string
]>
void 无返回值
▸ updateToStickTopSession(session_id
, to_type
, ext
, cb
): Promise
<[NIMResCode
, string
]>
更新置顶会话列表
Note
200:成功
Name | Type | Description |
---|---|---|
session_id |
string |
会话id |
to_type |
number |
会话类型 |
ext |
string |
扩展字段 |
cb |
UpdateStickTopSessionCallback |
更新置顶会话设置结果的回调函数 |
Promise
<[NIMResCode
, string
]>
void 无返回值
▸ cancelToStickTopSession(session_id
, to_type
, cb
): Promise
<[NIMResCode
, string
, NIMSessionType
]>
取消置顶会话列表
Note
200:成功
Name | Type | Description |
---|---|---|
session_id |
string |
会话id |
to_type |
number |
会话类型 |
cb |
CancelToStickTopSessionCallback |
取消置顶会话设置结果的回调函数 |
Promise
<[NIMResCode
, string
, NIMSessionType
]>
void 无返回值
▸ queryLastFewSessionAsync(limit
, cb
, jsonExtension
): Promise
<[NIMResCode
, SessionDataList
]>
查询指定数量的最后会话数据
Name | Type | Description |
---|---|---|
limit |
number |
要返回的最大数量 |
cb |
QuerySessionListCallback |
查询会话列表的回调函数 |
jsonExtension |
string |
json扩展参数(备用,目前不需要) |
Promise
<[NIMResCode
, SessionDataList
]>
void 无返回值
▸ queryAllRecentSessionAsync(msg_excluded_type_list
, cb
, jsonExtension
): Promise
<[NIMResCode
, SessionDataList
]>
查询会话列表,可指定最后一条会话消息要排除掉的类型(列表)
Name | Type | Description |
---|---|---|
msg_excluded_type_list |
NIMMessageType [] |
最后一条会话消息要排除掉的类型(列表),如果不排除任何消息,传入空列表 |
cb |
QuerySessionListCallback |
查询会话列表的回调函数 |
jsonExtension |
string |
json扩展参数(备用,目前不需要) |
Promise
<[NIMResCode
, SessionDataList
]>
void 无返回值
▸ deleteRecentSession(type
, id
, cb
, delete_roaming
): Promise
<[NIMResCode
, SessionData
, number
]>
删除最近联系人
Note
200:成功
Name | Type | Description |
---|---|---|
type |
NIMSessionType |
- |
id |
string |
对方的account id或者群组tid。 |
cb |
SessionChangeCallback |
最近会话列表项变更的回调函数 |
delete_roaming |
boolean |
是否同时删除漫游消息 |
Promise
<[NIMResCode
, SessionData
, number
]>
boolean 检查参数如果不符合要求则返回失败
▸ deleteAllRecentSession(cb
, jsonExtension
): Promise
<[NIMResCode
, SessionData
, number
]>
删除全部最近联系人
Note
200:成功
Name | Type | Description |
---|---|---|
cb |
SessionChangeCallback |
最近会话列表项变更的回调函数 |
jsonExtension |
string |
json扩展参数(备用,目前不需要) |
Promise
<[NIMResCode
, SessionData
, number
]>
void 无返回值
▸ deleteSessionRoamingMessage(to_type
, session_id
, cb
, ext
): Promise
<[NIMResCode
, number
, string
]>
删除某会话的漫游消息
Note
200:成功
Name | Type | Description |
---|---|---|
to_type |
number |
会话类型,双人0,群组1 (nim_msglog_def.h) |
session_id |
string |
- |
cb |
DeleteSessionRoamingMessageCallback |
删除结果 回调回调函数 |
ext |
string |
- |
Promise
<[NIMResCode
, number
, string
]>
boolean 检查参数如果不符合要求则返回失败
▸ setUnreadCountZeroAsync(type
, id
, cb
, jsonExtension
): Promise
<null
| [NIMResCode
, SessionData
, number
]>
最近联系人项未读数清零
Note
200:成功
Name | Type | Description |
---|---|---|
type |
NIMSessionType |
- |
id |
string |
对方的account id或者群组tid。 |
cb |
SessionChangeCallback |
最近会话列表项变更的回调函数 |
jsonExtension |
string |
json扩展参数(备用,目前不需要) |
Promise
<null
| [NIMResCode
, SessionData
, number
]>
boolean 检查参数如果不符合要求则返回失败
▸ setMultiUnreadCountZeroAsync(is_super_team
, zero_list
, cb
): Promise
<null
| [NIMResCode
, SessionData
[], number
]>
最近联系人项未读数清零
Note
200:成功
Name | Type | Description |
---|---|---|
is_super_team |
boolean |
会话列表中的会话是否是超大群会话 |
zero_list |
MultiUnreadCountZeroInfo [] |
清零的会话信息列表。 |
cb |
SetMultiUnreadCountZeroAsyncCallback |
最近会话列表项变更的回调函数 |
Promise
<null
| [NIMResCode
, SessionData
[], number
]>
boolean 检查参数如果不符合要求则返回失败
▸ setSessionTop(type
, id
, top
, cb
, jsonExtension
): Promise
<null
| [NIMResCode
, SessionData
, number
]>
设置会话项是否置顶(置顶属性只保存在本地)
Note
200:成功
Name | Type | Description |
---|---|---|
type |
NIMSessionType |
- |
id |
string |
对方的account id或者群组tid。 |
top |
boolean |
true - 置顶 false - 取消置顶 |
cb |
SessionChangeCallback |
回调函数 |
jsonExtension |
string |
json扩展参数(备用,目前不需要) |
Promise
<null
| [NIMResCode
, SessionData
, number
]>
boolean 检查参数如果不符合要求则返回失败
▸ setSessionExtendData(type
, id
, data
, cb
, jsonExtension
): Promise
<null
| [NIMResCode
, SessionData
, number
]>
设置会话项扩展数据(扩展数据只保存在本地)
Note
200:成功
Name | Type | Description |
---|---|---|
type |
NIMSessionType |
- |
id |
string |
对方的account id或者群组tid。 |
data |
string |
扩展数据,建议使用灵活可扩展的数据结构,例如Json |
cb |
SessionChangeCallback |
回调函数 |
jsonExtension |
string |
json扩展参数(备用,目前不需要) |
Promise
<null
| [NIMResCode
, SessionData
, number
]>
boolean 检查参数如果不符合要求则返回失败
▸ setAllUnreadCountZeroAsync(cb
, jsonExtension
): Promise
<null
| [NIMResCode
, SessionData
, number
]>
最近联系人项全部未读数清零
Note
200:成功
Name | Type | Description |
---|---|---|
cb |
SessionChangeCallback |
最近会话列表项变更的回调函数 |
jsonExtension |
string |
json扩展参数(备用,目前不需要) |
Promise
<null
| [NIMResCode
, SessionData
, number
]>
boolean 检查参数如果不符合要求则返回失败
▸ querySessionDataById(type
, id
, cb
, jsonExtension
): Promise
<[NIMResCode
, SessionData
]>
根据给定的id查询相应会话的信息
Note
200:成功
Name | Type | Description |
---|---|---|
type |
NIMSessionType |
- |
id |
string |
对方的account id或者群组tid。 |
cb |
QuerySessionDataCallback |
会话信息查询结果的回调函数 |
jsonExtension |
string |
json扩展参数(备用,目前不需要) |
Promise
<[NIMResCode
, SessionData
]>
void 无返回值
▸ queryHasmoreRoammsg(session_id
, to_type
, cb
): Promise
<[NIMResCode
, SessionRoamMsgHasMoreTagInfo
]>
查询会话是漫游消息未拉取信息
Note
200:成功
Name | Type | Description |
---|---|---|
session_id |
string |
会话id |
to_type |
number |
会话类型 |
cb |
QueryHasmoreRoammsgCallback |
查询会话是漫游消息未拉取信息回调函数 |
Promise
<[NIMResCode
, SessionRoamMsgHasMoreTagInfo
]>
void 无返回值
▸ queryAllHasmoreRoammsg(cb
): Promise
<[NIMResCode
, SessionRoamMsgHasMoreTagInfo
[]]>
查询所有漫游消息未拉取完全的会话
Name | Type | Description |
---|---|---|
cb |
QueryAllHasmoreRoammsgCallback |
结果回调 |
Promise
<[NIMResCode
, SessionRoamMsgHasMoreTagInfo
[]]>
void 无返回值
▸ updateHasmoreRoammsg(msg
, cb
): Promise
<[NIMResCode
]>
更新会话是漫游消息未拉取信息
Name | Type | Description |
---|---|---|
msg |
IMMessage |
对应的消息内容 |
cb |
UpdateHasmoreRoammsgCallback |
结果回调 |
Promise
<[NIMResCode
]>
void 无返回值
▸ deleteHasmoreRoammsg(session_id
, to_type
, cb
): Promise
<[NIMResCode
]>
删除会话是漫游消息未拉取信息
Name | Type | Description |
---|---|---|
session_id |
string |
会话id |
to_type |
NIMSessionType |
会话类型 |
cb |
DeleteHasmoreRoammsgCallback |
结果回调 |
Promise
<[NIMResCode
]>
void 无返回值
• session: NIMSessionAPI
• new NIMSession()
EventEmitter<NIMSessionEvents>.constructor
- chatroom/chatroom
- chatroom_def/chatroom_def
- nim/client
- nim/data_sync
- nim/friend
- nim/global
- nim/msglog
- nim/nos
- nim/online_session
- nim/pass_through_proxy
- nim/plugin
- nim/session
- nim/subscribe_event
- nim/super_team
- nim/sysmsg
- nim/talk
- nim/talkex
- nim/team
- nim/tool
- nim/user
- nim_def/client_def
- nim_def/data_sync_def
- nim_def/doc_trans_def
- nim_def/friend_def
- nim_def/global_def
- nim_def/msglog_def
- nim_def/nos_def
- nim_def/online_session_def
- nim_def/pass_through_proxy_def
- nim_def/plugin_def
- nim_def/session_def
- nim_def/subscribe_event_def
- nim_def/super_team_def
- nim_def/sysmsg_def
- nim_def/talk_def
- nim_def/talkex_def
- nim_def/team_def
- nim_def/tool_def
- nim_def/user_def
- node-nim
- qchat/attachment
- qchat/channel
- qchat/channel_category
- qchat/instance
- qchat/message
- qchat/role
- qchat/server
- qchat/system_notification
- qchat_def/attachment_def
- qchat_def/channel_def
- qchat_def/instance_def
- qchat_def/message_def
- qchat_def/public_def
- qchat_def/role_def
- qchat_def/server_def
- qchat_def/system_notification_def