Events

With events you can subscribe to various things which are happening inside the room.

For example you may want to hide the iframe when user leaves the meeting -> then you will subscribe to the userLeft event. For the full list of events please have a look at the navigation bar on the left.

You will subscribe to an event with the on() method and unsubscribe with the off() method. There is also the once() method for subscription, but it's only a one-time subscription and is used rarely in general. The events architecture is built upon the commonly used EventEmitter interface.

Templates for subscription/unsubscription:

sambaFrame.on('eventNameHere', (event) => {
   //Execute your own custom logic here
});

sambaFrame.once('eventNameHere', (event) => {
   //This will execute ONLY ONCE, even if the event happens a hundred times
});

const myCallback = (event) => {
   //Execute your own custom logic here
});
sambaFrame.on('eventNameHere', myCallback);
//........................................

//Unsubscribe if you want at some point later
sambaFrame.off('eventNameHere', myCallback);

There is a special event named '*', which can be useful for debugging purposes to see all incoming events and their data. sambaFrame.on('*', (event) => {

console.log(event);

});

Last updated