Skip to content

nim.session.NIMSession

Zvicii edited this page Feb 10, 2023 · 6 revisions

Class: NIMSession

nim/session.NIMSession

Hierarchy

Table of contents

Methods

Properties

Constructors

Methods

eventNames

eventNames(): keyof NIMSessionEvents[]

Return an array listing the events for which the emitter has registered listeners.

Returns

keyof NIMSessionEvents[]

Inherited from

EventEmitter.eventNames

Defined in

node_modules/eventemitter3/index.d.ts:15


listeners

listeners<T>(event): (...args: ArgumentMap<NIMSessionEvents>[Extract<T, keyof NIMSessionEvents>]) => void[]

Return the listeners registered for a given event.

Type parameters

Name Type
T extends keyof NIMSessionEvents

Parameters

Name Type
event T

Returns

(...args: ArgumentMap<NIMSessionEvents>[Extract<T, keyof NIMSessionEvents>]) => void[]

Inherited from

EventEmitter.listeners

Defined in

node_modules/eventemitter3/index.d.ts:20


listenerCount

listenerCount(event): number

Return the number of listeners listening to a given event.

Parameters

Name Type
event keyof NIMSessionEvents

Returns

number

Inherited from

EventEmitter.listenerCount

Defined in

node_modules/eventemitter3/index.d.ts:27


emit

emit<T>(event, ...args): boolean

Calls each of the listeners registered for a given event.

Type parameters

Name Type
T extends keyof NIMSessionEvents

Parameters

Name Type
event T
...args ArgumentMap<NIMSessionEvents>[Extract<T, keyof NIMSessionEvents>]

Returns

boolean

Inherited from

EventEmitter.emit

Defined in

node_modules/eventemitter3/index.d.ts:32


on

on<T>(event, fn, context?): NIMSession

Add a listener for a given event.

Type parameters

Name Type
T extends keyof NIMSessionEvents

Parameters

Name Type
event T
fn (...args: ArgumentMap<NIMSessionEvents>[Extract<T, keyof NIMSessionEvents>]) => void
context? any

Returns

NIMSession

Inherited from

EventEmitter.on

Defined in

node_modules/eventemitter3/index.d.ts:40


addListener

addListener<T>(event, fn, context?): NIMSession

Type parameters

Name Type
T extends keyof NIMSessionEvents

Parameters

Name Type
event T
fn (...args: ArgumentMap<NIMSessionEvents>[Extract<T, keyof NIMSessionEvents>]) => void
context? any

Returns

NIMSession

Inherited from

EventEmitter.addListener

Defined in

node_modules/eventemitter3/index.d.ts:45


once

once<T>(event, fn, context?): NIMSession

Add a one-time listener for a given event.

Type parameters

Name Type
T extends keyof NIMSessionEvents

Parameters

Name Type
event T
fn (...args: ArgumentMap<NIMSessionEvents>[Extract<T, keyof NIMSessionEvents>]) => void
context? any

Returns

NIMSession

Inherited from

EventEmitter.once

Defined in

node_modules/eventemitter3/index.d.ts:54


removeListener

removeListener<T>(event, fn?, context?, once?): NIMSession

Remove the listeners of a given event.

Type parameters

Name Type
T extends keyof NIMSessionEvents

Parameters

Name Type
event T
fn? (...args: ArgumentMap<NIMSessionEvents>[Extract<T, keyof NIMSessionEvents>]) => void
context? any
once? boolean

Returns

NIMSession

Inherited from

EventEmitter.removeListener

Defined in

node_modules/eventemitter3/index.d.ts:63


off

off<T>(event, fn?, context?, once?): NIMSession

Type parameters

Name Type
T extends keyof NIMSessionEvents

Parameters

Name Type
event T
fn? (...args: ArgumentMap<NIMSessionEvents>[Extract<T, keyof NIMSessionEvents>]) => void
context? any
once? boolean

Returns

NIMSession

Inherited from

EventEmitter.off

Defined in

node_modules/eventemitter3/index.d.ts:69


removeAllListeners

removeAllListeners(event?): NIMSession

Remove all listeners, or those of the specified event.

Parameters

Name Type
event? keyof NIMSessionEvents

Returns

NIMSession

Inherited from

EventEmitter.removeAllListeners

Defined in

node_modules/eventemitter3/index.d.ts:79


initEventHandlers

initEventHandlers(): void

注册全局回调

Returns

void

Defined in

ts/nim/session.ts:46


queryStickTopSessionList

queryStickTopSessionList(cb): Promise<[NIMResCode, string]>

查询置顶会话列表

Note

200:成功

Parameters

Name Type Description
cb null | QueryStickTopSessionListCallback 置顶会话列表查询结果的回调函数

Returns

Promise<[NIMResCode, string]>

void 无返回值

Defined in

ts/nim/session.ts:58


setToStickTopSession

setToStickTopSession(session_id, to_type, ext, cb): Promise<[NIMResCode, string]>

设置置顶会话

Note

200:成功

Parameters

Name Type Description
session_id string 会话id
to_type number 会话类型
ext string 扩展字段
cb null | SetToStickTopSessionCallback 置顶会话设置结果的回调函数

Returns

Promise<[NIMResCode, string]>

void 无返回值

Defined in

ts/nim/session.ts:80


updateToStickTopSession

updateToStickTopSession(session_id, to_type, ext, cb): Promise<[NIMResCode, string]>

更新置顶会话列表

Note

200:成功

Parameters

Name Type Description
session_id string 会话id
to_type number 会话类型
ext string 扩展字段
cb null | UpdateStickTopSessionCallback 更新置顶会话设置结果的回调函数

Returns

Promise<[NIMResCode, string]>

void 无返回值

Defined in

ts/nim/session.ts:102


cancelToStickTopSession

cancelToStickTopSession(session_id, to_type, cb): Promise<[NIMResCode, string, NIMSessionType]>

取消置顶会话列表

Note

200:成功

Parameters

Name Type Description
session_id string 会话id
to_type number 会话类型
cb null | CancelToStickTopSessionCallback 取消置顶会话设置结果的回调函数

Returns

Promise<[NIMResCode, string, NIMSessionType]>

void 无返回值

Defined in

ts/nim/session.ts:123


queryLastFewSessionAsync

queryLastFewSessionAsync(limit, cb, jsonExtension): Promise<[NIMResCode, SessionDataList]>

查询指定数量的最后会话数据

Parameters

Name Type Description
limit number 要返回的最大数量
cb null | QuerySessionListCallback 查询会话列表的回调函数
jsonExtension string json扩展参数(备用,目前不需要)

Returns

Promise<[NIMResCode, SessionDataList]>

void 无返回值

Defined in

ts/nim/session.ts:140


queryAllRecentSessionAsync

queryAllRecentSessionAsync(msg_excluded_type_list, cb, jsonExtension): Promise<[NIMResCode, SessionDataList]>

查询会话列表,可指定最后一条会话消息要排除掉的类型(列表)

Parameters

Name Type Description
msg_excluded_type_list NIMMessageType[] 最后一条会话消息要排除掉的类型(列表),如果不排除任何消息,传入空列表
cb null | QuerySessionListCallback 查询会话列表的回调函数
jsonExtension string json扩展参数(备用,目前不需要)

Returns

Promise<[NIMResCode, SessionDataList]>

void 无返回值

Defined in

ts/nim/session.ts:161


deleteRecentSession

deleteRecentSession(type, id, cb, delete_roaming): Promise<[NIMResCode, SessionData, number]>

删除最近联系人

Note

200:成功

Parameters

Name Type Description
type NIMSessionType -
id string 对方的account id或者群组tid。
cb null | SessionChangeCallback 最近会话列表项变更的回调函数
delete_roaming boolean 是否同时删除漫游消息

Returns

Promise<[NIMResCode, SessionData, number]>

boolean 检查参数如果不符合要求则返回失败

Defined in

ts/nim/session.ts:191


deleteAllRecentSession

deleteAllRecentSession(cb, jsonExtension): Promise<[NIMResCode, SessionData, number]>

删除全部最近联系人

Note

200:成功

Parameters

Name Type Description
cb null | SessionChangeCallback 最近会话列表项变更的回调函数
jsonExtension string json扩展参数(备用,目前不需要)

Returns

Promise<[NIMResCode, SessionData, number]>

void 无返回值

Defined in

ts/nim/session.ts:221


deleteSessionRoamingMessage

deleteSessionRoamingMessage(to_type, session_id, cb, ext): Promise<[NIMResCode, number, string]>

删除某会话的漫游消息

Note

200:成功

Parameters

Name Type Description
to_type number 会话类型,双人0,群组1 (nim_msglog_def.h)
session_id string -
cb null | DeleteSessionRoamingMessageCallback 删除结果 回调回调函数
ext string -

Returns

Promise<[NIMResCode, number, string]>

boolean 检查参数如果不符合要求则返回失败

Defined in

ts/nim/session.ts:243


setUnreadCountZeroAsync

setUnreadCountZeroAsync(type, id, cb, jsonExtension): Promise<null | [NIMResCode, SessionData, number]>

最近联系人项未读数清零

Note

200:成功

Parameters

Name Type Description
type NIMSessionType -
id string 对方的account id或者群组tid。
cb null | SessionChangeCallback 最近会话列表项变更的回调函数
jsonExtension string json扩展参数(备用,目前不需要)

Returns

Promise<null | [NIMResCode, SessionData, number]>

boolean 检查参数如果不符合要求则返回失败

Defined in

ts/nim/session.ts:275


setMultiUnreadCountZeroAsync

setMultiUnreadCountZeroAsync(is_super_team, zero_list, cb): Promise<null | [NIMResCode, SessionData[], number]>

最近联系人项未读数清零

Note

200:成功

Parameters

Name Type Description
is_super_team boolean 会话列表中的会话是否是超大群会话
zero_list MultiUnreadCountZeroInfo[] 清零的会话信息列表。
cb null | SetMultiUnreadCountZeroAsyncCallback 最近会话列表项变更的回调函数

Returns

Promise<null | [NIMResCode, SessionData[], number]>

boolean 检查参数如果不符合要求则返回失败

Defined in

ts/nim/session.ts:310


setSessionTop

setSessionTop(type, id, top, cb, jsonExtension): Promise<null | [NIMResCode, SessionData, number]>

设置会话项是否置顶(置顶属性只保存在本地)

Note

200:成功

Parameters

Name Type Description
type NIMSessionType -
id string 对方的account id或者群组tid。
top boolean true - 置顶 false - 取消置顶
cb null | SessionChangeCallback 回调函数
jsonExtension string json扩展参数(备用,目前不需要)

Returns

Promise<null | [NIMResCode, SessionData, number]>

boolean 检查参数如果不符合要求则返回失败

Defined in

ts/nim/session.ts:341


setSessionExtendData

setSessionExtendData(type, id, data, cb, jsonExtension): Promise<null | [NIMResCode, SessionData, number]>

设置会话项扩展数据(扩展数据只保存在本地)

Note

200:成功

Parameters

Name Type Description
type NIMSessionType -
id string 对方的account id或者群组tid。
data string 扩展数据,建议使用灵活可扩展的数据结构,例如Json
cb null | SessionChangeCallback 回调函数
jsonExtension string json扩展参数(备用,目前不需要)

Returns

Promise<null | [NIMResCode, SessionData, number]>

boolean 检查参数如果不符合要求则返回失败

Defined in

ts/nim/session.ts:380


setAllUnreadCountZeroAsync

setAllUnreadCountZeroAsync(cb, jsonExtension): Promise<null | [NIMResCode, SessionData, number]>

最近联系人项全部未读数清零

Note

200:成功

Parameters

Name Type Description
cb null | SessionChangeCallback 最近会话列表项变更的回调函数
jsonExtension string json扩展参数(备用,目前不需要)

Returns

Promise<null | [NIMResCode, SessionData, number]>

boolean 检查参数如果不符合要求则返回失败

Defined in

ts/nim/session.ts:416


querySessionDataById

querySessionDataById(type, id, cb, jsonExtension): Promise<[NIMResCode, SessionData]>

根据给定的id查询相应会话的信息

Note

200:成功

Parameters

Name Type Description
type NIMSessionType -
id string 对方的account id或者群组tid。
cb null | QuerySessionDataCallback 会话信息查询结果的回调函数
jsonExtension string json扩展参数(备用,目前不需要)

Returns

Promise<[NIMResCode, SessionData]>

void 无返回值

Defined in

ts/nim/session.ts:442


queryHasmoreRoammsg

queryHasmoreRoammsg(session_id, to_type, cb): Promise<[NIMResCode, SessionRoamMsgHasMoreTagInfo]>

查询会话是漫游消息未拉取信息

Note

200:成功

Parameters

Name Type Description
session_id string 会话id
to_type number 会话类型
cb null | QueryHasmoreRoammsgCallback 查询会话是漫游消息未拉取信息回调函数

Returns

Promise<[NIMResCode, SessionRoamMsgHasMoreTagInfo]>

void 无返回值

Defined in

ts/nim/session.ts:468


queryAllHasmoreRoammsg

queryAllHasmoreRoammsg(cb): Promise<[NIMResCode, SessionRoamMsgHasMoreTagInfo[]]>

查询所有漫游消息未拉取完全的会话

Parameters

Name Type Description
cb null | QueryAllHasmoreRoammsgCallback 结果回调

Returns

Promise<[NIMResCode, SessionRoamMsgHasMoreTagInfo[]]>

void 无返回值

Defined in

ts/nim/session.ts:483


updateHasmoreRoammsg

updateHasmoreRoammsg(msg, cb): Promise<[NIMResCode]>

更新会话是漫游消息未拉取信息

Parameters

Name Type Description
msg IMMessage 对应的消息内容
cb null | UpdateHasmoreRoammsgCallback 结果回调

Returns

Promise<[NIMResCode]>

void 无返回值

Defined in

ts/nim/session.ts:499


deleteHasmoreRoammsg

deleteHasmoreRoammsg(session_id, to_type, cb): Promise<[NIMResCode]>

删除会话是漫游消息未拉取信息

Parameters

Name Type Description
session_id string 会话id
to_type NIMSessionType 会话类型
cb null | DeleteHasmoreRoammsgCallback 结果回调

Returns

Promise<[NIMResCode]>

void 无返回值

Defined in

ts/nim/session.ts:516

Properties

session

session: NIMSessionAPI

Defined in

ts/nim/session.ts:39

Constructors

constructor

new NIMSession()

Overrides

EventEmitter<NIMSessionEvents&gt;.constructor

Defined in

ts/nim/session.ts:40

Clone this wiki locally