createSession()
createSession(array $options = array()) : \OpenTok\Session
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 by logging in to your
Vonage Video API account.
Parameters
array |
$options |
(Optional) This array defines options for the session. The array includes
the following keys (all of which are optional):
'archiveMode' (ArchiveMode) — Whether the session is automatically
archived (ArchiveMode::ALWAYS ) or not (ArchiveMode::MANUAL ).
By default, the setting is ArchiveMode.MANUAL , and you must call the
OpenTok->startArchive() method to start archiving. To archive the session
(either automatically or not), you must set the mediaMode key to
MediaMode::ROUTED .
'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.
'mediaMode' (MediaMode) — 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
recovery. With these features, 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.
|
Returns
\OpenTok\Session
— A Session object representing the new session. Call the
getSessionId()
method of this object to get the session ID. For example,
when using the OpenTok.js library, use this session ID when calling the
OT.initSession()
method.