Quick Start
The following code snippets show a basic example of using the core sdk to join and leave a room.
import { WherebyClient } from "@whereby.com/core";
const client = new WherebyClient();
const roomConnection = client.getRoomConnection();
const localMedia = client.getLocalMedia(); type JoinRoomOptions = {
roomUrl: string;
audio?: boolean;
video?: boolean;
}
async function joinRoom({roomUrl, audio = false, video = false}: JoinRoomOptions) {
/** If sending media, you need to start local media before initialising, for example:
async function startLocalMedia(stream: MediaStream) {
await localMedia.startMedia(stream);
}
**/
roomConnection.initialize({
localMediaOptions: {
audio,
video,
},
roomUrl,
});
try {
await roomConnection.joinRoom();
} catch(error) {
console.error("Could not join room", error);
return;
}
}Last updated
Was this helpful?

