Skip to main content

Events

Emit events to the meeting

The emitEvent method is used to emit custom events to the (client SDK) meeting. These can be listened for inside client SDK.

ParamTypeDescriptionDefault ValueRequired
eventNamestringName of the custom event.-true
dataanyEvent payload.-false
plugin.room.emitEvent('myAwesomeEvent');

Inside the Client SDK

const plugin = meeting.plugins.all.get('...');
plugin.on('myAwesomeEvent', () => {
// do something ...
});

Listen for events from the meeting

The on and addListener methods are used to listen for events (can also be user defined) coming from the client SDK.

ParamTypeDescriptionDefault ValueRequired
eventNameRoomEventsstringName of the event.-true
callbackFunctionThe callback method that gets execute when the event occurs.-true
Event NameDescription
peerLeftEmitted when a participant leaves the meeting. (not emitted for self)
peerJoinedEmitted when a new participant joins the meeting. (not emitted for self)
newChatMessageEmitted when a chat message is sent to the room or the current user (self).
type RoomEvents = 'peerLeft' | 'peerJoined' | 'newChatMessage';
plugin.room.on('peerJoined', () => { ... });

Alias:

plugin.room.addListener('peerJoined', () => { ... });
```

### Remove event listeners
```tsx
plugin.room.removeListeners('peerJoined');