Building custom client web application using Connector SDK
This tutorial will show you how to build your first simple web application using Connector APIs - the VidyoPlatform client SDK
Step 1 - prepare the environment
Nothing complex here - just create index.html file where you markup your web app structure. Let's also put some controls in that you will use further.
Also some basic page styles are already included as main.css, here they are:
Step 2 - load Connector SDK files
Include VidyoClient.js scripts into your page
VidyoClient.js is the main and only SDK library that contains all Connector API functions. In other words, you don't need to include any other javascript files for using Connector APIs. Remember to put it within <body>.
Include SDK styles
This stylesheet is used by VidyoClient.js internally, so it's important to include it into the page in order to prevent layout issues future.
We host the very latest VidyoClient.js and VidyoClient.css files following the links above. So you may load these files to your page from these URLs, however you also can download these files and host them on your web server, if you like.
Load above script onto the page
We need some kind of callback that will tell the app whether VidyoClient.js has been loaded onto the page successfully. For this we use onLoad() callback function of the added script, and it will invoke onVidyoClientLoaded() function below.
Step 3 - Create VidyoConnector object
Let's create an init() function and initialize Connector inside it:
In order to instantiate Connector object you will have to call CreateVidyoConnector() function of global VC variable that got initialized when VidyoClient.js loaded onto the page.
viewId parameter of CreateVidyoConnector() function
Let's not stop at each one, but rather review the most important one that you should understand at this point.
Here we should specify the ID of the DOM element where you want the composited video to be displayed. We suggest to use <div> block for this. You already have this control on your page as
Important - we strongly suggest to wrap "renderer" div into another outer container. If in future you would like to perform some UI actions with the renderer area (change visibility and so on), it's recommended to manipulate the outer container, and not the "renderer" directly.
Step 4 - Connect to video conference
Host and RoomKey
In previous tutorial you created a room on your tenant and received a RoomLink:
As you may guess, the following chunk of above link is your Host value:
And this one is a RoomKey:
Host (or your tenant URL) and RoomKey uniquely identify the meeting room. In other words - these are two values that your client application should get in order to connect to the room.
In a real world typically these values are being sent to the client apps from the backend server application after the room has been created.
After we got the necessary parameters (host, roomKey, displayName) we can proceed with joining the room.
Join the room
In order to join the room you just have to call ConnectToRoomAsGuest() API, and specify your Host and RoomKey values:
For simplicity, in this app we put few <input> controls where you can specify Host and RoomKey parameters. And we pass its values into ConnectToRoomAsGuest() API.
Callbacks
As you might noticed, there are three callback functions in the API call above:
onSuccess(): will be fired when connection to the room went successfully. This place is an indicator of the fact that your application has joined the call.
onFailure(): will be fired when connection attempt was made, but something went wrong and your app hasn't joined the call. Reason parameter may provide you with details why connection attempt was not successful.
onDisconnected(): will be fired when your application disconnected from the call.
Step 5 - Disconnect from video conference
In order to disconnect from ongoing conference you only have to call Disconnect() API:
Also you might noticed a handleDisconnect() function being called in onFailure() and onDisconnected() callbacks:
This function simply updates the UI, nothing more. It's up to you how to handle these events in your real app.
Important: When we spin up a VidyoPlatform tenant for you, we by default restrict requests to it from other domain origins. So, when you try to connect to the room on your tenant from your web app hosted at localhost or any custom domain, you may face CORS errors preventing you from joining. In this case please reach out to us with list of the domains you will be hosting your web app on, and we on our side will whitelist these domain for your tenant, and you will be able to connect to the rooms on your tenant.
Last updated