close search

Add Messaging, Voice, and Authentication to your apps with Nexmo APIs

Visit Nexmo


Public Member Functions

string GenerateToken (Role role=Role.PUBLISHER, double expireTime=0, string data=null, List< string > initialLayoutClassList=null)


string Id [get, set]
int ApiKey [get]
string ApiSecret [get]
string Location [get, set]
MediaMode MediaMode [get]
ArchiveMode ArchiveMode [get]

Detailed Description

Represents an OpenTok session. Use the CreateSession() method of the OpenTok class to create an OpenTok session. Use the Id property of the Session object to get the session ID.

Member Function Documentation

◆ GenerateToken()

string OpenTokSDK.Session.GenerateToken ( Role  role = Role.PUBLISHER,
double  expireTime = 0,
string  data = null,
List< string >  initialLayoutClassList = null 

Creates a token for connecting to an OpenTok session. In order to authenticate a user connecting to an OpenTok session that user must pass an authentication token along with the API key.

roleThe role for the token. Valid values are defined in the Role enum:
  • Role.SUBSCRIBER — A subscriber can only subscribe to streams.

  • Role.PUBLISHER — A publisher can publish streams, subscribe to streams, and signal. (This is the default value if you do not specify a role.)

  • Role.MODERATOR — In addition to the privileges granted to a publisher, in clients using the OpenTok.js library, a moderator can call the forceUnpublish() and forceDisconnect() method of the Session object.
expireTimeThe expiration time of the token, in seconds since the UNIX epoch. Pass in 0 to use the default expiration time of 24 hours after the token creation time. The maximum expiration time is 30 days after the creation time.
dataA string containing connection metadata describing the end-user. For example, you can pass the user ID, name, or other data describing the end-user. The length of the string is limited to 1000 characters. This data cannot be updated once it is set.
The token string.

Property Documentation

◆ ApiKey

int OpenTokSDK.Session.ApiKey

Your OpenTok API key.

◆ ApiSecret

string OpenTokSDK.Session.ApiSecret

Your OpenTok API secret.

◆ ArchiveMode

ArchiveMode OpenTokSDK.Session.ArchiveMode

Defines whether the session is automatically archived (ArchiveMode.ALWAYS) or not (ArchiveMode.MANUAL).

◆ Id

string OpenTokSDK.Session.Id

The session ID, which uniquely identifies the session.

◆ Location

string OpenTokSDK.Session.Location

The location hint IP address.

◆ MediaMode

MediaMode OpenTokSDK.Session.MediaMode

Defines whether the session will transmit streams using the OpenTok Media Router (MediaMode.ROUTED) or attempt to transmit streams directly between clients (MediaMode.RELAYED).