The Conference class allows you to embed a conferencing iframe into your web application. It requires a Client instance and supports customizable options for microphone, camera, and other settings. This guide explains how to integrate the Conference class from the datagram-network/conference-sdk
into your project to enable video conferencing features.
Copy constructor(client: Client | null, options: IConferenceOptions = {})
Copy type IConferenceOptions = {
metadata?: {
title?: string; // You can set a title for the conference (optional)
};
skipMediaSettings?: boolean; // If true, it skips asking for microphone/camera permissions at the start
turnOnMic?: boolean; // Automatically turns on microphone if true
turnOnCam?: boolean; // Automatically turns on camera if true
authorization?: string; // Your authorization token for accessing the conference
};
Copy mount(selector: string | HTMLElement): Promise<void>
Mounts the conference iframe into the specified DOM element.
Cleans up all components created by the mount method, removing the iframe and associated resources.
Tip: Use an event listener to handle these events (see example below).
Here is a basic example of how to create a client and conference, and then mount it on the page:
Copy import { Client, Conference, type IConferenceOptions } from "@datagram-network/conference-sdk";
let client: Client;
let conference: Conference;
const options: IConferenceOptions = {
skipMediaSettings: false,
turnOnCam: false,
turnOnMic: false,
authorization: "your_token_here",
};
// Create client instance
client = Client.create({
alias: "77am5",
origin: "http://localhost:8080",
});
// Create conference instance with client and options
conference = new Conference(client, options);
// Mount conference iframe inside the element with id "conference-root"
conference.mount(document.getElementById("conference-root"));
This example demonstrates how to integrate the Conference class into a Vue 3 application using TypeScript and the Composition API.
Copy div
button.p-2.border.rounded-full.bg-blue-500.text-white.p-4.min-w-32(@click='startRoom()' :class='{ "disabled:opacity-50": isLoading }')
span(v-show='!isLoading') Start room
.loader(v-show='isLoading')
div#datagram-frame.w-full.bg-black(ref='root' :class='[{ "fixed z-[10] block inset-0" : iframeMounted }]' v-show='iframeMounted')
Copy <script setup lang="ts">
import { useEventListener } from "@vueuse/core";
import { Client, Conference, type IConferenceOptions } from "@datagram-network/conference-sdk";
import { ref } from "vue";
const root = ref<HTMLElement>();
const iframeMounted = ref(false);
const isLoading = ref(false);
let client: Client;
let conference: Conference;
const options: IConferenceOptions = {
skipMediaSettings: false,
turnOnCam: false,
turnOnMic: false,
authorization: "your_token",
};
useEventListener("message", async (event) => {
switch (event.data) {
case "call_ended":
case "invalid_qr_code":
iframeMounted.value = false;
conference?.dispose();
break;
case "conference-ready":
case "call-ready":
isLoading.value = false;
iframeMounted.value = true;
break;
}
});
async function startRoom() {
client = Client.create({
alias: "77am5",
origin: "http://localhost:8080",
});
isLoading.value = true;
conference = new Conference(client, options);
await conference.mount(root.value as HTMLElement);
}
</script>
Copy #datagram-frame
height 100vh
@media mobile
height 100dvh
.loader {
width: 24px;
aspect-ratio: 1;
border-radius: 50%;
border: 4px solid #fff;
animation:
l20-1 0.8s infinite linear alternate,
l20-2 1.6s infinite linear;
}
@keyframes l20-1 {
0% {clip-path: polygon(50% 50%,0 0, 50% 0, 50% 0, 50% 0, 50% 0, 50% 0);}
12.5% {clip-path: polygon(50% 50%,0 0, 50% 0, 100% 0, 100% 0, 100% 0, 100% 0);}
25% {clip-path: polygon(50% 50%,0 0, 50% 0, 100% 0, 100% 100%, 100% 100%, 100% 100%);}
50% {clip-path: polygon(50% 50%,0 0, 50% 0, 100% 0, 100% 100%, 50% 100%, 0 100%);}
62.5% {clip-path: polygon(50% 50%,100% 0, 100% 0, 100% 0, 100% 100%, 50% 100%, 0 100%);}
75% {clip-path: polygon(50% 50%,100% 100%, 100% 100%, 100% 100%, 100% 100%, 50% 100%, 0 100%);}
100% {clip-path: polygon(50% 50%,50% 100%, 50% 100%, 50% 100%, 50% 100%, 50% 100%, 0 100%);}
}
@keyframes l20-2 {
0% {transform: scaleY(1) rotate(0deg);}
49.99% {transform: scaleY(1) rotate(135deg);}
50% {transform: scaleY(-1) rotate(0deg);}
100% {transform: scaleY(-1) rotate(-135deg);}
}