createSession()
createSession(array $options) : string
Creates a new OpenTok session and returns the session ID, which uniquely identifies
the session.
For example, when using the OpenTok JavaScript library, use the session ID when calling the
OT.initSession() method (to initialize an OpenTok session).
OpenTok sessions do not expire. However, authentication tokens do expire (see the
generateToken() method). Also note that sessions cannot explicitly be destroyed.
A session ID string can be up to 255 characters long.
Calling this method results in an OpenTokException in the event of an error.
Check the error message for details.
You can also create a session using the
OpenTok
REST API or the OpenTok dashboard.
Parameters
| array |
$options |
(Optional) This array defines options for the session. The array includes
the following keys (all of which are optional):
'mediaMode' (String) — Whether the session will transmit
streams using the OpenTok Media Router (MediaMode.ROUTED) or not
(MediaMode.RELAYED). By default, the mediaMode property
is set to MediaMode.RELAYED.
With the mediaMode parameter set to MediaMode.RELAYED, the
session will attempt to transmit streams directly between clients. If clients cannot
connect due to firewall restrictions, the session uses the OpenTok TURN server to relay
audio-video streams.
The OpenTok Media Router
provides the following benefits:
- The OpenTok Media Router can decrease bandwidth usage in multiparty sessions.
(When the
mediaMode parameter is set to MediaMode.ROUTED,
each client must send a separate audio-video stream to each client subscribing to
it.)
- The OpenTok Media Router can improve the quality of the user experience through
Intelligent Quality Control. With
Intelligent Quality Control, if a client's connectivity degrades to a degree that
it does not support video for a stream it's subscribing to, the video is dropped on
that client (without affecting other clients), and the client receives audio only.
If the client's connectivity improves, the video returns.
- The OpenTok Media Router supports the
archiving
feature, which lets you record, save, and retrieve OpenTok sessions.
'location' (String) — An IP address that the OpenTok servers
will use to situate the session in its global network. If you do not set a location hint,
the OpenTok servers will be based on the first client connecting to the session.
|
Returns
string
— A session ID for the new session. For example, when using the OpenTok.js
library, use this session ID when calling the OT.initSession() method.