Initializing a Session object
Before you can connect to a session, you will need to instantiate a session object using any of the client SDKs available.
Important: Please note that your App ID is your API key.
Instantiate a Session object by calling the OT.initSession() method with your App ID and the appropriate session ID:
The OT.initSession() method returns a Session object, through which subsequent API calls take place.
Note that calling the OT.initSession() method does not create a session; it creates a JavaScript Session object, which represents an existing session. You can create a session using the server-side SDK. See Creating a session.
If the user's browser does not support WebRTC, the call to OT.initSession() results in the page displaying a message to the user. To check for WebRTC support and prevent this message from being displayed, you can call the OT.checkSystemRequirements() method before calling OT.initSession():
Instantiate a Session.Builder object by calling the Session.Builder() constructor, passing in the appropriate Android application context, your Vonage Video API key, and a session ID. Then call the build() method of the Session.Builder object to create a Session object:
Note that calling the Session.Builder.build() method does not create a Vonage Video session; it creates the Java Session object, which represents an existing Vonage Video session. You create a Vonage Video session using the Vonage Video server-side libraries. See Creating a Vonage Video session.
Add a listener object for basic session-related events by calling the setSessionListener(Session.SessionListener listener) method of the Session object:
Implement the methods of the Session.SessionListener interface in the object you specify as the event listener object. These methods are called when session-related events occur.
Instantiate an OTSession object by calling the OTSession init(apiKey:sessionId:delegate:) method with your Vonage Video API key and the appropriate session ID:
Note that calling the OTSession init(apiKey: sessionId: delegate:) method does not create a Vonage Video session; it creates the Swift OTSession object, which represents an existing Vonage Video session. You create a Vonage Video session using the Vonage Video server-side libraries.
See Creating a Vonage Video session.
Implement the methods of the OTSessionDelegate protocol in the object you specify as the delegate object. These methods are called when session-related events occur.
Before you can connect to a session, instantiate an OTSession object by calling the [OTSession initWithApiKey: sessionId: delegate:] method with your Vonage Video API key and the appropriate session ID:
Note that calling the [OTSession initWithApiKey:sessionId:delegate:] method does not create a Vonage Video session; it creates the Objective-C OTSession object, which represents an existing Vonage Video session. You create a Vonage Video session using the Vonage Video server-side libraries. See Creating a Vonage Video session.
Implement the methods of the OTSessionDelegate protocol in the object you specify as the delegate object. These methods are called when session-related events occur.
Instantiate a Session object by calling the Session() constructor, passing in the appropriate Windows application context, your Vonage Video API key, and a Vonage Video session ID:
Note that calling the Session() constructor does not create a Vonage Video session; it creates a C# Session object, which represents an existing Vonage Video session. You create a Vonage Video session using the Vonage Video server-side libraries. See Creating a Vonage Video session.
You will want to add handlers for basic session-related events:
You will want to implement each of the callback methods. For example, this method handles ConnectionCreated event (which occurs when the client connects to the Vonage Video session):
Note: The Session class implements the System.IDisposable interface. Be sure to call the Dispose() method of the Session object to release their resources when you no longer need the object (for example, when the app or window is closing).
Create a structure of type otc_session_callbacks, and function pointers to it callback function members. For example:
Use the user_data member of the otc_session_callbacks structure to set data you may want to reference in the callback functions. In this example, we set it to a pointer to a string object. But it could be a pointer to an instance of some other type that contains meaningful information.
The other members of the otc_session_callbacks structure are callback functions that are called when events related to the Vonage Video session occur. The previous example includes callbacks for the following:
on_connected\-- Called when theotc_session_connect()function (see below) successfully connects the instance to a Vonage Video session.on_stream_received-- Called when there is a new stream in the Vonage Video session (when another client publishes a stream to the session).on_stream_dropped-- Called when another client's stream is dropped from the Vonage Video session. This can happen when the client stops publishing the stream or if the client's network connection drops.on_disconnected-- Called when a the application disconnects from the Vonage Video session (see below).on_error-- Called when an error occurs in connecting to the session. This function includes parameters for an error string and an error code that is defined by theotc_session_error_codeenum.
All callbacks will not be made on the application or main thread but on an internal thread. The application should return the callback as quickly as possible to avoid blocking the internal thread.
See otc_session_callbacks in the Vonage Video Linux SDK reference for details on each of the callback functions.
After initializing the the otc_session_callbacks structure, call the otc_session_new() function, passing in your Vonage Video API key string, the Vonage Video session ID string, and a pointer to the otc_session_callbacks structure:
The otc_session_new() function returns an otc_session structure, which represents a Vonage Video session.
To use advanced session settings, call the otc_session_new_with_settings(), instead of the otc_session_new() function. This function takes an settings parameter that is a pointer to an otc_session_settings struct that defines the advanced settings. For example, the following code uses the otc\_session_settings_new () function to instantiate an otc_session_settings struct and calls otc_session_settings_set_connection_events_suppressed(OTC_TRUE) to have the SDK suppress connection events, to support large interactive video sessions. It then passes the otc_session_settings struct into the otc_session_new_with_settings() function:
In addition to otc_session_settings_set_connection_events_suppressed(), the following functions let you set advanced settings for a session:
otc_session_settings_set_custom_ice_config()— Enables custom ICE sever configuration. This is part of the configurable TURN feature.otc_session_settings_set_ip_whitelist()— This supports the allowed IP address feature available as an add-on feature.otc_session_settings_set_proxy_url()— Sets an IP proxy URL. See the IP Proxy developer guide.