\OpenTokSession

Represents an OpenTok session.

Use the OpenTok.createSession() method to create an OpenTok session. Use the getSessionId() method of the Session object to get the session ID.

Summary

Methods
Properties
Constants
getSessionId()
getLocation()
getMediaMode()
generateToken()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
No private properties found
N/A

Methods

getSessionId()

getSessionId()

Returns the session ID, which uniquely identifies the session.

getLocation()

getLocation()

Returns the location hint IP address. See the OpenTok.createSession() method.

getMediaMode()

getMediaMode()

Returns true if the session's streams will be transmitted directly between peers; returns false if the session's streams will be transmitted using the OpenTok media server.

See the OpenTok.createSession() method.

generateToken()

generateToken(array $options) : string

Creates a token for connecting to the session. In order to authenticate a user, cthe client passes a token when connecting to the session.

For testing, you can also use the OpenTok dashboard page to generate test tokens.

Parameters

array $options

This array defines options for the token. This array include the following keys, all of which are optional:

  • 'role' (string) — One of the constants defined in the RoleConstants class. The default role is publisher
  • 'expireTime' (int) — The timestamp for when the token expires, in milliseconds since the Unix epoch. The default expiration time is 24 hours after the token creation time. The maximum expiration time is 30 days after the token creation time.
  • 'data' (string) — A 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.

Returns

string —

The token string.