JavaScript

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.

  1. Copy the following code and paste it below the existing code in your app.js file after the initializeSession() 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.

以下の言語で利用可能:
JavaScript Java Swift
手順
1
Overview
2
Before You Begin
3
Configure a Vonage Video Application
4
Creating the Project Folders and HTML Template
5
Setting Up Authentication
6
Connecting to the Session
7
Sending a Signal
8
Receiving a Signal
9
Testing your Code in a Browser
10
A little bit of CSS customization
11
Conclusion