Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface IMEventInterface

Example:

const instance = new SDK()

instance.on('logined', loginResult => { console.log(loginResult.connectionId) }

Hierarchy

  • IMEventInterface

Index

Properties

addSuperTeamMembers: [result: { accounts: string[]; members: SuperTeamMember[]; team: SuperTeam }]

超级群添加

addTeamMembers: [addTeamMembersResult: { accounts: string[]; members: TeamMember[]; team: Team }]

收到了群成员的更新

broadcastMsgs: [msgs: NIM_BroadcastMessage[]]

收到广播消息(在线或者离线同步收到均会触发)

clearServerHistoryMsgs: [result: { sessionId: string; time: number }[]]

在初始化同步/多端同步时,收到了清除历史消息的通知

createSuperTeam: [team: SuperTeam, owner: StrAnyObj]

收到了多端同步创建群的情况

owner 群的所有者

createTeam: [team: Team, owner: StrAnyObj]

收到了多端同步创建群的情况

owner 群的所有者

示例场景

deleteSelfMsgs: [result: DeleteSelfMsgsResult[]]

调用 deleteSelfMsgs后,账号的多端登录实例会收到此通知

disconnect: []

连接断开

  • 注: 此事件不包含被踢而断开的情况
    v0.14.0 之前触发条件: 1. 手动断开。 2. 在连接断开后, 自动登录超过重试上限次数。
    v0.14.0,包含本版本,更新触发条件: 1. 手动断开。2. 在连接断开后,自动登录超过重试上限次数。3. 登陆保持阶段第一次断开时触发
dismissSuperTeam: [result: { teamId: string }]

超级群解散

dismissTeam: [result: { teamId: string }]

触发了解散群

friends: [friends: FriendProfile[]]

同步时收到了好友相关资料

kicked: [kickedReason: TKickedReason]

被踢下线

logined: [loginResult: LoginResult]

初始化成功登陆

msg: [msg: IMMessage]
msgReceipts: [msgReceipts: TeamMsgReceipt[] | p2pMsgReceipt[]]

收到了消息已读,包含单聊和群聊

example
nim.on('msgReceipts', msgReceipts => {
for (let _ of msgReceipts) {
// getMsgsBySessionIds 这个是开发者自行维护的函数
const msgArr = getMsgsBySessionIds(_.sessionId)
for (let msg of msgArr) {
// 只有自己发送的消息才需要标记已读回执
if (msg.scene === 'p2p' && msg.from === myAccount && msg.time < Number(_.msgReceiptTime)) {
// 消息已被对端阅读
msg.status = 'receipt'
}
}
}
})
multiPortLogin: [multiLoginResults: MultiPortLoginResult[]]

多端登陆通知

multiSyncUpdateCloudSession: [session: NIMECloudSession]

多端同步收到的远端会话变更

mySuperTeamMembers: [superTeamMembers: Partial<SuperTeamMember>[]]

收到了当前账号所在超级群的成员信息。在同步阶段以及在本端和其它端修改自己超级群的成员信息时会触发此事件。

myTeamMembers: [teamMembers: Partial<TeamMember>[]]

收到了当前账号所在群的成员信息。在同步阶段以及在本端和其它端修改自己的群成员信息时会触发此事件。

已废弃。请使用 updateTeamMember 事件替代该事件

示例场景

proxyMsg: [proxyMsg: TProxyMsg]

收到了代理消息(透传的)

pushEvents: [events: PushEvent[]]

收到了订阅事件

relations: [relations: Relations]

同步收到的关系,包括黑名单和静音列表

removeSuperTeamMembers: [result: { accounts: string[]; team: SuperTeam }]

移除超级群成员

removeTeamMembers: [result: { accounts: string[]; team: Team }]

收到成员离群,例如成员 A 调用了 leaveTeam 离群,其他成员会收到这个事件。

sessions: [sessions: Session[]]
superTeams: [teams: SuperTeam[]]

收到了初始化同步的群

syncFriend: [result: IMEventSyncFriendResult]

多端同步时收到了好友相关的资料

syncMyNameCard: [syncMyNameCardResult: UserNameCard]

同步时收到了个人信息

syncOfflineMsgs: [syncRoamingMsgsResult: SyncOfflineMsgsResult]
syncRoamingMsgs: [syncRoamingMsgsResult: SyncRoamingMsgsResult]
syncSysMsgs: [sysMsgs: SystemMessage[]]

同步漫游/离线时收到的系统消息

syncdone: []
sysMsg: [sysMsg: SystemMessage]
teamMsgReceipts: [msgReceipts: TeamMsgReceipt[]]
deprecated

这个字段即将废弃,所有的属性被移入 IMEventInterface.msgReceipts 中 收到了群已读

示例场景

teams: [teams: Team[]]
transferSuperTeam: [result: { from: { account: string; id: string; type: SuperTeamMemberType; updateTime: number }; team: SuperTeam; to: { account: string; id: string; type: SuperTeamMemberType; updateTime: number } }]

触发转让超级群事件

transferTeam: [tranferTeamResult: TTransferTeamResult]

收到了转让群

updateBlackList: [updateBlackListResult: { account: string; isAdd: boolean }]

收到了黑名单更新通知

updateMuteList: [updateMuteListResult: { account: string; isAdd: boolean }]

收到了静音列表更新通知

updateMyNameCard: [myNameCard: UserNameCard]

收到了更新个人信息通知

updateSession: [session: Session]
updateSuperTeam: [team: SuperTeam]

超级群更新

updateSuperTeamManagers: [updateSuperTeamManagersResult: TUpdateSuperTeamManagersResult]

超级群管理员更新

updateSuperTeamMember: [teamMember: SuperTeamMember]

超级群成员更新的多端同步

updateSuperTeamMembersMute: [result: { accounts: string[]; members: { account: string; id: string; mute: boolean; teamId: string; updateTime: number }[]; mute: boolean; team: SuperTeam }]

超级群成员静音事件

updateSystemMessages: [result: { from: string; idServer: string; state: "read" | "deleted" | "none" | "pass" | "decline" | "invalid"; type: "applyTeam" | "rejectTeamApply" | "teamInvite" | "rejectTeamInvite" | "friendRequest" | "deleteFriend" | "recallMsgP2p" | "recallMsgTeam" | "recallMsgSuperTeam" | "deleteMsgP2pOneWay" | "deleteMsgTeamOneWay" | "applySuperTeam" | "rejectSuperTeamApply" | "superTeamInvite" | "rejectSuperTeamInvite" | "customP2p" | "customTeam" | "customSuperTeam" }[]]

收到了系统消息

updateTeam: [team: Team]

收到了群的更新信息

updateTeamManagers: [updateTeamManagersResult: TUpdateTeamManagersResult]

收到了群管理员的更新

updateTeamMember: [member: TeamMember]

收到了多端同步来更新群成员的情况

updateTeamMembersMute: [result: TUpdateTeamMembersMute]

收到了更新群成员静音

updateUserInfo: UserNameCard

其他用户资料更新回调

触发时机

当收到其他用户发来的消息时,如果该用户资料中有更新,或之前从未同步过该用户资料,SDK 会触发该回调并返回该用户的最新资料。

示例场景

users: [users: UserNameCard[]]

同步时收到了其他用户相关资料

willReconnect: [params: TWillReconnect]

开始自动重连