Updated on 2025-05-29 GMT+08:00

Creating an Event Listener

API Description

This API is used to create an event listener.

Precautions

  1. The return object of this API can be used to listen to meeting events. Create an event listener in advance and listen to events.
  2. When the on method is called for listening, the events that can be listened can be obtained by calling the API for Obtaining the Event List.

Method Definition

1
createEventListener: EventEmitter

Parameter Description

None

Return Values

Table 1 Return values

Type

Description

EventEmitter

A Node.js event emitter object is returned. The on method of the object can be called to listen to events. For details about the event list, see Table 2.

Event Notification Reference describes the parameters of each event.

EventEmitter reference: https://github.com/browserify/events#readme

Sample Code
// Create a listener.
let listener = HWMeeting.createEventListener();

// Listen to the notification of the meeting pause event.
listener.on('conf_state', function(data){
  console.log(data)
});

// Listen to all events.
HWMeeting.getEventList().forEach(event => {
      listener.on(event, (eventData) => {
        console.log(event, JSON.stringify(eventData));
      });
});