Session
Represents an OpenTok session.
Use the \OpenTok\OpenTok->createSession() method to create an OpenTok session. Use the getSessionId() method of the Session object to get the session ID.
Table of Contents
generateToken() : string : Creates a token for connecting to the session. In order to authenticate a user, the client passes a token when connecting to the session.
getArchiveMode() : ArchiveMode : Defines whether the session is automatically archived (ArchiveMode::ALWAYS) or not (ArchiveMode::MANUAL).
getE2EE() : bool : Whether end-to-end encryption is set for the session.
getLocation() : string : Returns the location hint IP address.
getMediaMode() : MediaMode : Returns MediaMode::RELAYED if the session's streams will be transmitted directly between peers; returns MediaMode::ROUTED if the session's streams will be transmitted using the OpenTok Media Router.
getSessionId() : string : Returns the session ID, which uniquely identifies the session.
Methods
generateToken()
Creates a token for connecting to the session. In order to authenticate a user, the client passes a token when connecting to the session.
public generateToken([array<string|int, mixed> $options = array() ][, bool $legacy = false ]) : string
For testing, you can also generate tokens or by logging in to your OpenTok Video API account.
Parameters
$options : array<string|int, mixed> = array() : 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.
$legacy : bool = false
: Connection tokens are now SHA-256 signed JWTs.
Set this to true to create a token using the legacy T1 format.
Return values
string —
The token string.
getArchiveMode()
Defines whether the session is automatically archived (ArchiveMode::ALWAYS) or not (ArchiveMode::MANUAL).
public getArchiveMode() : ArchiveMode
See OpenTok->createSession() and ArchiveMode.
Return values
getE2EE()
Whether end-to-end encryption is set for the session.
public getE2EE() : bool
Return values
bool —
getLocation()
Returns the location hint IP address.
public getLocation() : string
Return values
string —
getMediaMode()
Returns MediaMode::RELAYED if the session's streams will be transmitted directly between peers; returns MediaMode::ROUTED if the session's streams will be transmitted using the OpenTok Media Router.
public getMediaMode() : MediaMode
See OpenTok->createSession() and MediaMode.
Return values
getSessionId()
Returns the session ID, which uniquely identifies the session.
public getSessionId() : string
Return values
string —