Leaving the Room
Once the call is finished or when a user decides to exit the room, it is essential to provide a mechanism for them to leave the room gracefully. This ensures that resources are released, and the user is properly disconnected from the session.
Sample Code for Leaving the Room
Here’s a simple asynchronous function that allows a user to leave the room:
async function leaveRoom(videoedgeInstance) {
await videoedgeInstance.leaveRoom(); // Leave the room
console.log("Left the room");
}
Usage Example
You can call this function in response to a user action, such as clicking a "Leave Room" button:
// Example usage
const videoedgeInstance = /* initialized videoedge instance */;
// Leave room on button click
document.getElementById("leaveButton").addEventListener("click", async () => {
await leaveRoom(videoedgeInstance);
});
Summary
By implementing the leaveRoom function, you complete the lifecycle of a room in your application. This allows users to exit the room gracefully, ensuring that all necessary cleanup is performed. This concludes the basic functionality for managing a video call using the Videoedge SDK. With the ability to join a room, manage media streams, and leave the room, you have the essential building blocks for a robust video conferencing application.