@baasi/baasi-client-lib
v1.1.63
Published
Baasi WebRTC library
Downloads
125
Readme
baasi-client-lib
baasi-client-lib is web SDK to add real-time voice and video in you web applications.
Installation
NPM
npm i @baasi/baasi-client-lib
Usage
Simple example for connecting room. For more checkout API Documentation
import {
Room,
connect,
createLocalTracks,
ConnectedParticipant,
} from "@baasi/baasi-client-lib";
createLocalTracks({
audio: true,
video: true
}).then((tracks) => {
const room: Room = connect('$YOUR_JOIN_TOKEN_HERE', {
tracks: tracks,
});
room.on('participantConnected', participantConnected);
room.on('participantDisconnected', participantDisconnected);
room.on('remoteTrackUpdated', remoteTrackUpdated);
room.on('localTrackUpdated', localTrackUpdated);
});
function participantConnected(
participant: ConnectedParticipant,
participantType: ParticipantType
) {
const div = document.createElement('div');
div.id = participant.id;
div.innerText = participant.name;
document.body.appendChild(div);
}
function participantDisconnected(participant: ConnectedParticipant) {
document.getElementById(participant.id).remove();
}
function remoteTrackUpdated(track: RemoteTrack) {
console.log(`Remote participant ${track.kind} track updated: ${track.states.producerMuted}`);
}
function localTrackUpdated(track: RemoteTrack) {
console.log(`Local participant ${track.kind} track updated: ${track.states.producerMuted}`);
}