Polyv Help Center

Help Center

Module Events

Updated: 2026-01-19 09:16:42

1. V2 Chat Room SDK Setup Completion Callback

Event: ChatEvents.ChatSdkV2Setuped

2. Chat Room Info Change

The chat room module stores basic chat room state information. Listen for chat room state changes through this event.

Event: ChatEvents.ChatInfoChange

Callback Parameters: Object object, detailed type description as follows

Property Name Description Type
chatInfo Chat room info ChatModuleInfo

Example:

watchCore.chat.eventEmitter.on(ChatEvents.ChatInfoChange, (evt) => {
  const chatInfo = evt.chatInfo;
  console.log('聊天室是否已关闭', chatInfo.chatRoomIsClosed);
});

3. Chat Room Reconnection Success Event

Description: This event is triggered when the chat room successfully reconnects after a disconnection.

Event: ChatEvents.ChatReconnectSuccess

Example:

watchCore.chat.eventEmitter.on(ChatEvents.ChatReconnectSuccess, () => {
  console.info("重连成功!")
});

4. Chat Room Connection Failure Event

Description: This event is triggered when the chat room connection fails due to network disconnection or other factors.

Event: ChatEvents.ChatConnectFail

Callback Parameters: Object object, detailed type description as follows

Property Name Description Type
reason Reason for connection failure ChatConnectFailReason

Example:

watchCore.chat.eventEmitter.on(ChatEvents.ChatConnectFail, (data) => {
  confirm({
    message: '聊天室连接失败,无法与其他人互动,立即刷新重试?',
    onConfirm: () => location.reload(),
  });
});

5. Chat Message Event

Description: This event is triggered when a chat message is received.

Event: ChatEvents.ChatMessage

Callback Parameters: Object object, detailed type description as follows

Property Name Description Type
chatMsg Chat message object ChatMsgType
isChatReplayMsg Whether it is a chat replay message boolean

Example:

// 聊天消息列表
const chatMsgList: ChatMsgType[] = [];

// 聊天消息事件
watchCore.chat.eventEmitter.on(ChatEvents.ChatMessage, (data) => {
// 插入到聊天消息列表
  chatMsgList.push(data.chatMsg);
  // 渲染聊天消息...
});

6. Replace Chat Message Event

When calling message sending methods such as sendSpeakMsg, the ChatEvents.ChatMessage event is called back before sending to the server. At this point, the message id is a local id. After sending to the server and receiving the message id callback, this event is triggered. Upon receiving this event, update the message object and rendering information based on the id.

Additionally, if the server detects an inappropriate image when sending an image message, it is also updated through this event.

Event: ChatEvents.ReplaceChatMessage

Callback Parameters: Object object, detailed type description as follows

Property Name Description Type
id Replaced message id string
chatMsg New message object ChatMsgType

Example:

watchCore.chat.eventEmitter.on(ChatEvents.ReplaceChatMessage, (data) => {
  // 需要被替换的消息 id
  const replaceId = data.id;
  // 新的消息对象
  const chatMsg = data.chatMsg;

  const index = chatMsgList.findIndex((item) => item.id === replaceId);
  if (index !== -1) {
    chatMsgList[index] = chatMsg;
  }
  // 将视图的消息节点替换...
});

7. Like Event

Description: Listen for user like events through this event.

Event: ChatEvents.ChatLike

Callback Parameters: Object object, detailed type description as follows

Property Name Description Type
count Number of likes number
realtimeLikes Real-time like count number
userId User id string
nick User nickname string
isSelf Whether it is a self-like boolean

Example:

watchCore.chat.eventEmitter.on(ChatEvents.ChatLike, (data) => {
  console.log('实时点赞数:', data.realtimeLikes);
  console.log('该观众的点赞次数', data.count);
  console.log('点赞的观众 id', data.userId);
  console.log('点赞的观众昵称', data.nick);
});

8. Like Count Change Event

Description: Listen for like count change events through this event. Update the like count display on the page after the callback.

Event: ChatEvents.ChatLikeCountChange

Callback Parameters: Object object, detailed type description as follows

Property Name Description Type
realtimeLikes Real-time like count number

Example:

watchCore.chat.eventEmitter.on(ChatEvents.ChatLikeCountChange, (data) => {
  console.log('实时点赞数:', data.realtimeLikes);
});

9. Emotional Feedback Event

Description: Listen for user emotional feedback events through this event.

Event: ChatEvents.ChatEmotionalFeedback

Callback Parameters: Object object, detailed type description as follows

Property Name Description Type
type Emotion type EmotionalFeedbackType
count Count number

Example:

watchCore.chat.eventEmitter.on(ChatEvents.ChatEmotionalFeedback, (data) => {
  console.log('类型:', data.type); // EmotionalFeedbackType
  console.log('数量:', data.count);
});

10. Chat Room User Login Event

Description: This event is triggered when a viewer enters the chat room.

Event: ChatEvents.ChatUserLogin

Callback Parameters: Object object, detailed type description as follows

Property Name Description Type
user User info ChatMessageUser

Example:

watchCore.chat.eventEmitter.on(ChatEvents.ChatUserLogin, (data) => {
  const user = data.user;
  toast.info(`欢迎 ${user.nick} 进入`);
});

11. Chat Room User Logout Event

Description: This event is triggered when a viewer leaves the chat room.

Event: ChatEvents.ChatUserLogout

Callback Parameters: Object object, detailed type description as follows

Property Name Description Type
userId User userId string

Example:

watchCore.chat.eventEmitter.on(ChatEvents.ChatUserLogout, (data) => {
  const userId = data.userId;
  console.log('退出的用户 id', userId);
});

12. Current User Duplicate Login Event

Description: This event is triggered when a user logs into the chat room repeatedly. After triggering, the current page will not be able to receive any chat room messages.

Event: ChatEvents.CurrentUserRelogin

Callback Parameters: Object object, detailed type description as follows

Property Name Description Type
causeBy Error source string

Example:

watchCore.chat.eventEmitter.on(ChatEvents.CurrentUserRelogin, (data) => {
  toast.errot('您已在其他地方登录,3 秒后将推出该页面');
  setTimeout(() => {
    location.replace('跳出到页面地址');
  }, 3000);
});

13. Clear Chat Room Event

Description: This event is triggered after an administrator clears the chat history.

Event: ChatEvents.ClearMsgHistory

Example:

watchCore.chat.eventEmitter.on(ChatEvents.ClearMsgHistory, () => {
  console.log('管理员清空历史记录,todo 清空聊天记录列表');
});

14. Delete a Message Event

Description: This event is triggered after an administrator deletes a historical message.

Event: ChatEvents.RemoveChatMsg

Callback Parameters: Object object, detailed type description as follows

Property Name Description Type
id Deleted message id string

Example:

watchCore.chat.eventEmitter.on(ChatEvents.RemoveChatMsg, (data) => {
  console.log('管理员删除历史消息,删除的消息 id:', data.id);
});

15. Chat Room Close Event

Description: This event is triggered after the instructor or administrator closes the chat room.

Event: ChatEvents.CloseChatRoom

Example:

watchCore.chat.eventEmitter.on(ChatEvents.CloseChatRoom, () => {
  watchCore.chat.sendSystemMsg('聊天室已关闭');
});

16. Chat Room Open Event

Description: This event is triggered after the instructor or administrator opens the chat room.

Event: ChatEvents.OpenChatRoom

Example:

watchCore.chat.eventEmitter.on(ChatEvents.CloseChatRoom, () => {
  watchCore.chat.sendSystemMsg('聊天室已打开');
});

17. Online User Count Change Event

Description: When viewers come online/go offline, this event is called back to obtain the real-time online user count.

Event: ChatEvents.OnlineUserCountChange

Callback Parameters: Object object, detailed type description as follows

Property Name Description Type
onlineUserCount Real-time online user count number

Example:

watchCore.chat.eventEmitter.on(ChatEvents.OnlineUserCountChange, (data) => {
  console.log('在线人数改变:', data.onlineUserCount);
});

18. Online User List Change Event

Description: This event is called back when polling of the online user list begins.

Event: ChatEvents.OnlineUserListChange

Callback Parameters: UserListResult

Example:

watchCore.chat.eventEmitter.on(ChatEvents.OnlineUserListChange, (data) => {
  console.log('在线用户列表:', data.userlist);
});

19. Chat Message Replay - Reload

Description: Notify external components to reload the chat replay data.

Event: ChatEvents.ChatMsgReplayReload

Callback Parameters: Object object, detailed type description as follows

Property Name Description Type
seconds - number

Example:

watchCore.chat.eventEmitter.on(ChatEvents.ChatMsgReplayReload, () => {
  // initChatMsgRender
  console.log('需要重新加载聊天重放数据渲染表格');
});

20. Chat Message Replay Status

Event: ChatEvents.ChatMsgReplayStatusChange

Callback Parameters: Object object, detailed type description as follows

Property Name Description Type
status Replay status ChatMsgReplayStatus

Example:

watchCore.chat.eventEmitter.on(ChatEvents.ChatMsgReplayStatusChange, (params) => {
  console.log('聊天重放状态变更:', params.status);
});

21. Exceeded Maximum Online Users in Live Room

Event: ChatEvents.OverMaxOnlineCount

22. Whitelist Remove User

Event: ChatEvents.WhiteListRemoveUser

23. Comment Pinned Event

Event: ChatEvents.SpeakToTop

Callback Parameters: ChatMsgSpeakTopType

24. Comment Unpinned Event

Event: ChatEvents.SpeakCancelTop

Callback Parameters: Object | undefined

25. Exceeded Channel Login Limit Event

Event: ChatEvents.OverLoginLimit

Callback Parameters: Object object, detailed type description as follows

Property Name Description Type
isStartLiveOverLogin RELOGIN triggered at the start of the live stream due to exceeding the channel's user limit boolean
联系客服,在线咨询