Connecting to the Session
You may have noticed the initializeSession() method being called in the last step after getting the session ID and token. This method initializes a session object and then connects to the session, but we haven't defined it in our code yet.
- Copy the following code and paste it below the existing code in your
app.jsfile after theinitializeSession()line:
// Handling all of our errors here by alerting them
function handleError(error) {
if (error) {
alert(error.message);
}
}
function initializeSession() {
session = OT.initSession(applicationId, sessionId);
// Connect to the session
session.connect(token, function(error) {
if (error) {
handleError(error);
}
});
}
OT.initSession() takes our Application ID and Session ID to set up which video session we will be connecting to. This does not immediately connect us to the session, since applications may have some additional bootstrapping before fully connecting.
session.connect() finally tells the SDK to connect to the API. It takes our token, which is our authentication token, and connects us to the API.
Basic text chat
Follow this tutorial to build basic text chat from scratch using the Vonage Video API. It is the quickest way to build a proof of concept for this functionality on the video platform.