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
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 });