createSession(array $options) : \OpenTok\Session
Creates a new OpenTok session and returns the session ID, which uniquely identifies
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
(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
ArchiveMode::ALWAYS) or not (
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
'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
is set to
mediaMode parameter set to
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
OpenTok Media Router provides the following benefits:
- The OpenTok Media Router can decrease bandwidth usage in multiparty sessions.
mediaMode parameter is set to
each client must send a separate audio-video stream to each client subscribing to
- 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
feature, which lets you record, save, and retrieve OpenTok sessions.
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