Skip to main content

Public Interface

Two of the most common things you want to do with the library are:

  • Let a user join a room
  • Respond to things happening inside the room

Receive Events

In order to receive Eyeson room events register a listener using the OnEvent method provided. Remember to register a handler before starting a room otherwise you might miss some initial events.

const handleEvent = function() { /* ... */ };

eyeson.onEvent(handleEvent); // attach listener for Eyeson events
eyeson.start(token); // initiate and join the room
eyeson.destroy(); // destroy and cleanup a session
eyeson.offEvent(handleEvent); // remove listener for Eyeson events
info

Note that start is a convenient shorthand which handles connecting, fetching initial data and joining the room for you. If you want more granular control over this process you can always use corresponding lower level methods:

eyeson.onEvent(event => {
if (event.connectionStatus === 'connected') {
eyeson.join({ audio: true, video: true }); // join the room with audio and video
}
});
eyeson.connect(token); // prepare connection
note

Calling eyeson.connect will keep the meeting alive until the user actually joins. This can be especially useful to create a pre-meeting part.

Since v1.6.2 you can even start or join with any custom MediaStream. Read more about custom media streams.

eyeson.start('ACCESS_KEY', { stream });

Send Operations

Send operations are fundamental for interacting with the meeting library, enabling users to trigger actions within the system. By utilizing the send method, developers can transmit specific event types that initiate various functions throughout the meeting lifecycle.

eyeson.send({ type: '...' });

Find more details about the types of events to be received and sent in the features section.