Events
The plugin provides certain methods to emit custom events to other peers in the meeting. You can emit these events to all peers or selected peers.
Emit a custom event to other peers
| Param | Type | Description | Default Value | Required | 
|---|---|---|---|---|
| eventName | string | Name of the event. | - | true | 
| data | any | Event payload. | - | false | 
| peerIds | string[] | IDs of peers to whom you wish to emit the event. | - | false | 
Note a few event names are reserved and cannot be used:
enabled- Emitted when a plugin is enabled.closed- Emitted when a plugin is closed.dyteStateUpdate- Emitted when the state of the plugin has changed.ready- Emitted when the plugin is ready to exchange data with client SDK.toggleViewMode- Emitted when the control is toggled for users with view-only permissions for a plugin.
plugin.emit('myAwesomeEvent', { key: 'value' });
const peerIds = ['...'];
plugin.emit('myAwesomeEvent', { key: 'value' }, peerIds);
Listen for custom events from other peers
plugin.on('myAwesomeEvent', (data) => {
  console.log('do something');
});
Alias:
plugin.addListener('myAwesomeEvent', (data) => {
  console.log('do something');
});
Remove event listeners
plugin.removeListeners('myAwesomeEvent');