Session
public class Session extends Observable
Represents an OpenTok session in which the client is participating. The first step in using the OpenTok Android SDK is to initialize a Session instance by calling the Session() constructor.
When you create the Session instance, you pass in the OpenTok session ID, token, and API key. You get an API key when you sign up for an OpenTok account. For test purposes, you can generate test session IDs and tokens by logging in to your Vonage Video API account. Use the OpenTok server-side libraries to generate session IDs and tokens in your shipping app.
Nested types: Session.Capabilities, Session.SessionListener, Session.ConnectionListener, Session.StreamPropertiesListener, Session.StreamCaptionsPropertiesListener, Session.SignalListener, Session.ArchiveListener, Session.ReconnectionListener, Session.MuteListener, Session.SessionOptionsProvider, Session.SessionOptions, Session.ConfigurableSessionOptions, Session.Builder
Properties
| Name | Type | Description |
|---|---|---|
sessionListener |
Session.SessionListener | protected |
connectionListener |
Session.ConnectionListener | protected |
streamPropertiesListener |
Session.StreamPropertiesListener | protected |
streamCaptionsPropertiesListener |
Session.StreamCaptionsPropertiesListener | protected |
signalListener |
Session.SignalListener | protected |
archiveListener |
Session.ArchiveListener | protected |
reconnectionListener |
Session.ReconnectionListener | protected |
muteListener |
Session.MuteListener | protected |
context |
Context | protected |
apiKey |
String | protected |
sessionId |
String | protected |
apiUrl |
URL | protected |
Methods
| Name | Description |
|---|---|
Session(builder) |
|
connect(token) |
Connects to the OpenTok session provided in the Session constructor, using the provided authentication token. |
disableForceMute() |
Disables the active mute state of the session. |
disconnect() |
Disconnects from this session. |
finalize() |
Called by the garbage collector when it determines that there are no more references to the Session object. |
forceDisconnect(connection) |
Forces a client to disconnect from the session. |
forceMuteAll(excludedStreams) |
Forces all publishers in the session (except for those publishing excluded streams) to mute audio. |
forceMuteStream(stream) |
Forces the publisher of a specified stream to mute its audio. |
getCapabilities() → {Session.Capabilities} |
Indicates whether the client can publish and subscribe to streams in the session, based on the role assigned to the token used to connect to the session. |
getConnection() → {Connection} |
Returns the Connection corresponding to this client's connection to this Session. |
getSessionId() → {String} |
Returns the Session ID passed in during instantiation. |
onArchiveStarted(id, name) |
Called when an archive of the session starts recording. |
onArchiveStopped(id) |
Called when an archive of the session stops being recorded. |
onConnected() |
Invoked when the client connects to the OpenTok session. |
onConnectionCreated(connection) |
Invoked when another client connects to the session. |
onConnectionDestroyed(connection) |
Invoked when another client leaves the session. |
onDisconnected() |
Invoked when the client is no longer connected to the OpenTok session. |
onError(error) |
Invoked when something goes wrong when connecting or connected to the session. |
onMuteForced(info) |
Invoked when a moderator mutes streams in the session or disables the mute state in the session. |
onPause() |
Call this method when the app's activity pauses. |
onReconnected() |
Invoked when the local client has reconnected to the OpenTok session after its network connection was lost temporarily. |
onReconnecting() |
Invoked when the local client has lost its connection to an OpenTok session and is trying to reconnect. |
onResume() |
Call this method when the app's activity resumes. |
onSignalReceived(type, data, connection) |
Called when a signal is received in the session. |
onStreamDropped(stream) |
Invoked when another client stops publishing a stream to this OpenTok session. |
onStreamHasAudioChanged(stream, hasAudio) |
Called when a stream in the session changes between having audio and not having audio. |
onStreamHasCaptionsChanged(stream, hasCaptions) |
Called when a stream in the session changes between having captions and not having captions. |
onStreamHasVideoChanged(stream, hasVideo) |
Called when a stream in the session changes between having video and not having video. |
onStreamReceived(stream) |
Invoked when a there is a new stream published by another client in this OpenTok session. |
onStreamVideoDimensionsChanged(stream, width, height) |
Called when the video dimensions of a stream in the session change. |
onStreamVideoTypeChanged(stream, videoType) |
Called when the video type of a stream in the session change. |
publish(publisher) |
Starts a Publisher streaming to the session. |
reportIssue() → {String} |
Report that your app experienced an issue. |
sendSignal(type, data) |
Sends a signal to all clients in a session. |
sendSignal(type, data, retryAfterReconnect) |
Sends a signal to all clients in a session. |
sendSignal(type, data, connection) |
Sends a signal to a specific client in a session. |
sendSignal(type, data, connection, retryAfterReconnect) |
Sends a signal to a specific client in a session.This version of the method includes a retryAfterReconnect parameter. |
setArchiveListener(listener) |
Sets an ArchiveListener object to monitor when an archive recording starts or stops in this session. |
setConnectionListener(listener) |
Sets a ConnectionListener object to monitor when other clients connect and disconnect from this session. |
setEncryptionSecret(secret) |
Sets the end-to-end encryption secret used by all publishers and subscribers. |
setMuteListener(listener) |
Sets a MuteListener object to monitor when mute forced is sent in this session. |
setReconnectionListener(listener) |
Sets a ReconnectionListener object to be notified when the client is attempting to reconnect or reconnected to an OpenTok session. |
setSessionListener(listener) |
Sets a SessionListener object to monitor state changes for this Session object. |
setSignalListener(listener) |
Sets a SignalListener object to monitor when signals are sent in this session. |
setStreamCaptionsPropertiesListener(listener) |
Sets a StreamCaptionsPropertiesListener object to monitor properties of stream captions property. |
setStreamPropertiesListener(listener) |
Sets a StreamPropertiesListener object to monitor properties of streams in this session change. |
subscribe(subscriber) |
Start receiving and rendering audio-video stream data for the specified subscriber. |
unpublish(publisher) |
Disconnects the Publisher from the session. |
unsubscribe(subscriber) |
Stops subscribing (receiving a stream) to a specified subscriber in the session. |
Session(builder)
Parameters:
| Name | Type | Description |
|---|---|---|
builder |
Session.Builder |
connect(token)
Connects to the OpenTok session provided in the Session constructor, using the provided authentication token.
When the session connects, the
Session.SessionListener#onConnected(Session session) method is
called.
If the session fails to connect, the
Session.SessionListener#onError(Session session, OpentokError error)
method is called.
Parameters:
| Name | Type | Description |
|---|---|---|
token |
String | The token for the user. See Token Creation Overview. |
disableForceMute()
Disables the active mute state of the session. After you call this method, new streams published to the session will no longer have audio muted.
After you call the Session#forceMuteAll(Iterable)
method (or a moderator in another client makes a call to mute all streams), any streams
published after the moderation call are published with audio muted. Call the
disableForceMute() method to remove the mute state of a session
(so that new published streams are not automatically muted).
Calling this method causes the Session.MuteListener#onMuteForced(Session session, MuteForcedInfo info)
method to be called, with the getActive() method of the info object
returning false.
Check the canForceMute property of the object returned by calling
Session#getCapabilities() to see if you can call this function successfully.
This is reserved for clients that have connected with a token that has been assigned
the moderator role (see the
Token Creation
documentation).
See:
: - Session.MuteListener#onMuteForced(Session session, MuteForcedInfo info)
- Session#getCapabilities()
- Session#forceMuteAll(Iterable)
- Muting the audio of streams in a session
disconnect()
Disconnects from this session. All Subscriber and Publisher instances
will be disconnected. As a best practice, before calling this method,
call the Session#unpublish(PublisherKit) method for all publishers
and wait for the PublisherKit.PublisherListener#onStreamDestroyed(Stream)
callback. This ensures the complete removal of publishers, especially if
network connectivity issues prevent removal due to the reconnection feature,
which may keep publisher streams alive for potential reconnection.
When the session disconnects, the
Session.SessionListener#onDisconnected(Session session) method is
called.
finalize()
Called by the garbage collector when it determines that there are no more references to the Session object.
See:
: - Throws Throwable
forceDisconnect(connection)
Forces a client to disconnect from the session.
While you can use Session#forceDisconnect(Connection)
to terminate your connection, calling the disconnect method is simpler.
An error is returned if the client's role does not include permissions
required to force other users to disconnect. You define a client's role
when you create the user token. When a connection is terminated using
this method, Session.SessionListener#onDisconnected(Session),
Session.ConnectionListener#onConnectionDestroyed(Connection)
and PublisherKit.PublisherListener#onStreamDestroyed(Stream)
callbacks are dispatched in the same way as they would be if the
connection had terminated itself using Session#disconnect().
Parameters:
| Name | Type | Description |
|---|---|---|
connection |
Connection | The connection to disconnect. |
forceMuteAll(excludedStreams)
Forces all publishers in the session (except for those publishing excluded streams) to mute audio.
Also, any streams that are published after the call to the forceMuteAll() method
are published with audio muted. You can remove the mute state of a session by calling the
Session#disableForceMute() method. After you call the Session#disableForceMute()
method, new streams published to the session will no longer have audio muted.
Calling this method causes the Session.MuteListener#onMuteForced(Session session, MuteForcedInfo info)
method to be called in each client connected to the session, with the getActive()
method of the info object returning true.
Check the canForceMute property of the object returned by calling
Session#getCapabilities() to see if you can call this function successfully.
This is reserved for clients that have connected with a token that has been assigned
the moderator role (see the
Token Creation
documentation).
Parameters:
| Name | Type | Description |
|---|---|---|
excludedStreams |
Iterable<Stream> | The object that represent the streams to be excluded from the force mute request. This includes the stream that should not be muted. |
See:
: - Session.MuteListener#onMuteForced(Session session, MuteForcedInfo info)
- Session#getCapabilities()
- Session#disableForceMute()
- Session#forceMuteStream(Stream stream)
- Session.MuteListener#onMuteForced(Session session, MuteForcedInfo info)
- PublisherKit.MuteListener#onMuteForced()
- Muting the audio of streams in a session
forceMuteStream(stream)
Forces the publisher of a specified stream to mute its audio.
Check the canForceMute property of the object returned by calling
Session#getCapabilities() to see if you can call this function successfully.
This is reserved for clients that have connected with a token that has been assigned
the moderator role (see the
Token Creation
documentation).
Parameters:
| Name | Type | Description |
|---|---|---|
stream |
Stream | The object that represent the stream for the force mute request. This includes the stream that should be muted. |
See:
: - Session#getCapabilities()
- Session#forceMuteAll(Iterable)
- PublisherKit.MuteListener#onMuteForced()
- Muting the audio of streams in a session
getCapabilities() → {Session.Capabilities}
Indicates whether the client can publish and subscribe to streams in the session, based on
the role assigned to the token used to connect to the session. This method returns
null until you have connected to a session and the
Session.SessionListener#onConnected(Session session) method has been called.
Returns:
Session.Capabilities
getConnection() → {Connection}
Returns the Connection corresponding to this client's connection
to this Session.
When a Stream is created, the
Session.SessionListener#onStreamReceived(Session session, Stream stream)
method is called. Compare the Connection object returned by the
Stream#getConnection method with the Connection object returned
by Sesssion.getConnection() to see if the new stream is published
by your client.
See:
: - Session.SessionListener#onConnected(Session session)
- Session.SessionListener#onStreamReceived(Session session, Stream stream)
- Stream#getConnection
Returns:
The OpenTok Session ID for this instance.
getSessionId() → {String}
Returns the Session ID passed in during instantiation.
Returns:
The OpenTok Session ID for this instance.
onArchiveStarted(id, name)
Called when an archive of the session starts recording. In response to this method, you may want to add a user interface notification (such as an icon in the Publisher view) that indicates the session is being recorded.
If you extend the Session class, you can override this method instead of the
onArchiveStarted() method of the Session.ArchiveListener
interface.
Parameters:
| Name | Type | Description |
|---|---|---|
id |
String | The unique ID of the archive. |
name |
String | The name of the archive (if one was provided when the archive was created). |
onArchiveStopped(id)
Called when an archive of the session stops being recorded. In response to this method, you may want to remove a user interface notification (such as an icon in the Publisher view) the session recording has stopped.
If you extend the Session class, you can override this method instead of the
onArchiveStopped() method of the Session.ArchiveListener
interface.
Parameters:
| Name | Type | Description |
|---|---|---|
id |
String | The unique ID of the archive. |
onConnected()
Invoked when the client connects to the OpenTok session.
If you extend the Session class, you can override this method instead of the
onConnected() method of the Session.SessionListener
interface.
onConnectionCreated(connection)
Invoked when another client connects to the session. The
Connection object represents the client's connection to the session.
Note that this method is invoked when other clients connect to
the session. When your own client client connects, the
Session.SessionListener#onConnected(Session session) method
is called.
If you extend the Session class, you can override this method instead of the
onConnectionCreated() method of the Session.ConnectionListener
interface.
Parameters:
| Name | Type | Description |
|---|---|---|
connection |
Connection | The new connection in the session. |
onConnectionDestroyed(connection)
Invoked when another client leaves the session. The Connection object
represents the client's previous connection to the session. When your
own client client disconnects, the
Session.SessionListener#onDisconnected(Session session)
method is called.
If you extend the Session class, you can override this method instead of the
onConnectionDestroyed() method of the Session.ConnectionListener
interface.
Parameters:
| Name | Type | Description |
|---|---|---|
connection |
Connection | The connection that left the session the session. |
onDisconnected()
Invoked when the client is no longer connected to the OpenTok session.
If you extend the Session class, you can override this method instead of the
onDisconnected() method of the Session.SessionListener
interface.
onError(error)
Invoked when something goes wrong when connecting or connected to the session. After this method is invoked, the Session should be treated as dead and unavailable. Do not attempt to reconnect or to call other methods of the Session object.
This method is called if the attempt to connect to the session fails.
It is also called if the connection to the session drops due to an error after
a successful connection, and in this case the method is called just before
the Session.SessionListener#onDisconnected(Session session) method is called.
If you extend the Session class, you can override this method instead of the
onError() method of the Session.SessionListener
interface.
Parameters:
| Name | Type | Description |
|---|---|---|
error |
OpentokError | An error describing the cause for error. |
onMuteForced(info)
Invoked when a moderator mutes streams in the session or disables the mute state in the session.
If you extend the Session class, you can override this method instead of the
onMuteForced() method of the Session.MuteListener interface.
Parameters:
| Name | Type | Description |
|---|---|---|
info |
MuteForcedInfo | Call the getActive method of this object to determine if the moderator has muted streams in the session (true) or disabled the mute state in the session (false). |
See:
: - Session#forceMuteAll(Iterable)
- Session#disableForceMute()
- Session.MuteListener#onMuteForced(MuteForcedInfo)
- PublisherKit.MuteListener#onMuteForced()
- Muting the audio of streams in a session
onPause()
Call this method when the app's activity pauses. This pauses the video renderer and capturer of any publishers to the session. It also pauses the video renderers of all subscribers.
Cameras used by OpenTok publishers are now released when you call this method.
Publishers reacquire cameras when you call the Session#onResume() method.
onReconnected()
Invoked when the local client has reconnected to the OpenTok session after its
network connection was lost temporarily. When the connection is lost, the
Session.ReconnectionListener#onReconnecting(Session session) method is called,
prior to the Session.ReconnectionListener.onReconnected(Session session)
method. If the client cannot reconnect to the session, the
Session.SessionListener#onDisconnected(Session session) method is called.
Any existing publishers and subscribers are automatically reconnected when the client reconnects and this method is called.
By default, any signals initiated by the the local client using the
Session#sendSignal(String type, String data) method are sent when the client
reconnects. To prevent any signals initiated while disconnected from being sent,
use the Session#sendSignal(String type, String data, boolean retryAfterReconnect)
method to send the signal, and set the retryAfterReconnect parameter to
false. (All signals sent by other clients while your client was disconnected
are received upon reconnecting.)
If you extend the Session class, you can override this method instead of the
onReconnected() method of the Session.ReconnectionListener
interface.
See:
: - onReconnecting()
onReconnecting()
Invoked when the local client has lost its connection to an OpenTok session and is trying
to reconnect. This results from a loss in network connectivity. If the client can
reconnect to the session, the
Session.ReconnectionListener#onReconnected(Session session) method is called.
Otherwise, if the client cannot reconnect, the
Session.SessionListener#onDisconnected(Session session) method is called.
In response to this method being called, you may want to provide a user interface notification, to let the user know that the app is trying to reconnect to the session and that audio-video streams are temporarily disconnected.
If you extend the Session class, you can override this method instead of the
onReconnecting() method of the Session.ReconnectionListener
interface.
See:
: - onReconnected()
onResume()
Call this method when the app's activity resumes. This resumes the video renderer and capturer of any publisher to the session. It also resumes the video renderers of all subscribers.
Any cameras (used by OpenTok publishers) which were released when you
called the Session#onPause() method are reacquired when you call
Session.onResume().
onSignalReceived(type, data, connection)
Called when a signal is received in the session.
If you extend the Session class, you can override this method instead of the
onSignalReceived() method of the Session.SignalListener
interface.
Parameters:
| Name | Type | Description |
|---|---|---|
type |
String | The type string of the signal. |
data |
String | The signal data. |
connection |
Connection | The connection identifying the client that sent the message. This value can be null. |
onStreamDropped(stream)
Invoked when another client stops publishing a stream to this OpenTok session.
If you extend the Session class, you can override this method instead of the
onStreamDropped() method of the Session.SessionListener
interface.
Parameters:
| Name | Type | Description |
|---|---|---|
stream |
Stream | A Stream object representing the dropped stream, which can be used to identify a Subscriber. |
onStreamHasAudioChanged(stream, hasAudio)
Called when a stream in the session changes between having audio and not having audio.
If you extend the Session class, you can override this method instead of the
onStreamHasAudioChanged() method of the Session.StreamPropertiesListener
interface.
Parameters:
| Name | Type | Description |
|---|---|---|
stream |
Stream | The stream. |
hasAudio |
int | Whether the stream has audio (true) or not ( false). |
onStreamHasCaptionsChanged(stream, hasCaptions)
Called when a stream in the session changes between having captions and not having captions.
If you extend the Session class, you can override this method instead of the
onStreamHasCaptionsChanged() method of the Session.StreamPropertiesListener
interface.
Parameters:
| Name | Type | Description |
|---|---|---|
stream |
Stream | The stream. |
hasCaptions |
int | Whether the stream has captions (true) or not ( false). |
onStreamHasVideoChanged(stream, hasVideo)
Called when a stream in the session changes between having video and not having video.
If you extend the Session class, you can override this method instead of the
onStreamHasVideoChanged() method of the Session.StreamPropertiesListener
interface.
Parameters:
| Name | Type | Description |
|---|---|---|
stream |
Stream | The stream. |
hasVideo |
int | Whether the stream has video (true) or not ( false). |
onStreamReceived(stream)
Invoked when a there is a new stream published by another client in this OpenTok session.
If you extend the Session class, you can override this method instead of the
onStreamReceived() method of the Session.SessionListener
interface.
Parameters:
| Name | Type | Description |
|---|---|---|
stream |
Stream | A Stream object representing the new stream, which can be used to create a Subscriber. |
onStreamVideoDimensionsChanged(stream, width, height)
Called when the video dimensions of a stream in the session change.
If you extend the Session class, you can override this method instead of the
onStreamVideoDimensionsChanged() method of the Session.StreamPropertiesListener
interface.
Parameters:
| Name | Type | Description |
|---|---|---|
stream |
Stream | The stream. |
width |
int | The new width of the stream, in pixels. |
height |
int | The new height of the stream, in pixels. |
onStreamVideoTypeChanged(stream, videoType)
Called when the video type of a stream in the session change.
If you extend the Session class, you can override this method instead of the
onStreamVideoTypeChanged() method of the Session.StreamPropertiesListener
interface.
Parameters:
| Name | Type | Description |
|---|---|---|
stream |
Stream | The stream. |
videoType |
int | The new video type of the stream. |
publish(publisher)
Starts a Publisher streaming to the session.
Parameters:
| Name | Type | Description |
|---|---|---|
publisher |
PublisherKit | The Publisher that you want to stream to the session. |
reportIssue() → {String}
Report that your app experienced an issue. You can use the issue ID with the Inspector or when discussing an issue with the TokBox support team.
Returns:
The ID associated with the issue.
sendSignal(type, data)
Sends a signal to all clients in a session.
Parameters:
| Name | Type | Description |
|---|---|---|
type |
String | The type of the signal. The type is also set in the Session.SignalListener#onSignalReceived(Session session, String type, String data, Connection connection) method. |
data |
String | The data to send. The limit to the size of data is 8kB. |
See:
: - sendSignal(String type, String data, Connection connection)
- sendSignal(String type, String data, boolean retryAfterReconnect)
- Session.SignalListener#onSignalReceived(Session session, String type, String data, Connection connection)
sendSignal(type, data, retryAfterReconnect)
Sends a signal to all clients in a session. This version of the method includes
a retryAfterReconnect parameter.
Parameters:
| Name | Type | Description |
|---|---|---|
type |
String | The type of the signal. The type is also set in the Session.SignalListener#onSignalReceived(Session session, String type, String data, Connection connection) method. |
data |
String | The data to send. The limit to the size of data is 8kB. |
retryAfterReconnect |
boolean | Upon reconnecting to the session, whether to send any signals that were initiated while disconnected. If your client loses its connection to the OpenTok session, due to a drop in network connectivity, the client attempts to reconnect to the session, and the Session.ReconnectionListener#onReconnecting(Session session) method is called. By default, signals initiated while disconnected are sent when (and if) the client reconnects to the OpenTok session. You can prevent this by setting the retryAfterReconnect parameter to false. (The default value is true.) |
See:
: - sendSignal(String type, String data)
- Session.ReconnectionListener#onReconnecting(Session session)
- Session.SignalListener#onSignalReceived(Session session, String type, String data, Connection connection)
sendSignal(type, data, connection)
Sends a signal to a specific client in a session.
Parameters:
| Name | Type | Description |
|---|---|---|
type |
String | The type of the signal. The type is also set in the Session.SignalListener#onSignalReceived(Session session, String type, String data, Connection connection) method. |
data |
String | The data to send. The limit to the size of data is 8kB. |
connection |
Connection | A Connection object. The Connection object represents the connection of a client to the session. This is the client to which the message is sent. (See Session.ConnectionListener#onConnectionCreated(Session session, Connection connection) and Connection. |
See:
: - sendSignal(String type, String data)
- sendSignal(String type, String data, Connection connection, boolean retryAfterReconnect)
- Session.SignalListener#onSignalReceived(Session session, String type, String data, Connection connection)
sendSignal(type, data, connection, retryAfterReconnect)
Sends a signal to a specific client in a session.This version of the method includes
a retryAfterReconnect parameter.
Parameters:
| Name | Type | Description |
|---|---|---|
type |
String | The type of the signal. The type is also set in the Session.SignalListener#onSignalReceived(Session session, String type, String data, Connection connection) method. |
data |
String | The data to send. The limit to the size of data is 8kB. |
connection |
Connection | A Connection object. The Connection object represents the connection of a client to the session. This is the client to which the message is sent. (See Session.ConnectionListener#onConnectionCreated(Session session, Connection connection) and Connection. |
retryAfterReconnect |
boolean | Upon reconnecting to the session, whether to send any signals that were initiated while disconnected. If your client loses its connection to the OpenTok session, due to a drop in network connectivity, the client attempts to reconnect to the session, and the Session.ReconnectionListener#onReconnecting(Session session) method is called. By default, signals initiated while disconnected are sent when (and if) the client reconnects to the OpenTok session. You can prevent this by setting the retryAfterReconnect parameter to false. (The default value is true.) |
See:
: - sendSignal(String type, String data)
- sendSignal(String type, String data, Connection connection)
- sendSignal(String type, String data, boolean retryAfterReconnect)
- Session.SignalListener#onSignalReceived(Session session, String type, String data, Connection connection)
setArchiveListener(listener)
Sets an ArchiveListener object to monitor when an archive recording
starts or stops in this session.
Parameters:
| Name | Type | Description |
|---|---|---|
listener |
Session.ArchiveListener | The ArchiveListener instance. |
setConnectionListener(listener)
Sets a ConnectionListener object to monitor when other clients
connect and disconnect from this session.
Parameters:
| Name | Type | Description |
|---|---|---|
listener |
Session.ConnectionListener | The ConnectionListener instance. |
setEncryptionSecret(secret)
Sets the end-to-end encryption secret used by all publishers and subscribers.
See the End-to-end encryption developer guide.
The session must have been configured as end-to-end encrypted using the server SDK. If the
session is already known not to be end-to-end encrypted, this method reports
OpentokError.ErrorCode#EncryptionNotEnabled and any existing publishers and
subscribers receive the same error and are dropped. If that is not known yet (for example,
when the secret is set before the session connects), this method succeeds and the error is
reported later, when publishing or subscribing.
Passing null or an empty string resets (clears) the previously set encryption
secret. Resetting the secret is always allowed, even on a session that is known not to be
end-to-end encrypted.
Any other secret must be between 8 and 256 bytes long when UTF-8 encoded; otherwise
OpentokError.ErrorCode#InvalidEncryptionSecret is reported.
A new secret takes effect for the publishers and subscribers that are already running, as well as for those created afterwards. Resetting the secret, however, only takes effect for publishers and subscribers created afterwards: those that are already running keep encrypting and decrypting with the previous secret until they are recreated.
Parameters:
| Name | Type | Description |
|---|---|---|
secret |
String | Value of the encryption secret, or null or an empty string to reset the previously set encryption secret. |
setMuteListener(listener)
Sets a MuteListener object to monitor when mute forced is
sent in this session.
Parameters:
| Name | Type | Description |
|---|---|---|
listener |
Session.MuteListener | The MuteListener instance. |
setReconnectionListener(listener)
Sets a ReconnectionListener object to be notified when the client is
attempting to reconnect or reconnected to an OpenTok session.
Parameters:
| Name | Type | Description |
|---|---|---|
listener |
Session.ReconnectionListener | The ReconnectionListener instance. |
setSessionListener(listener)
Sets a SessionListener object to monitor state changes for this
Session object.
Parameters:
| Name | Type | Description |
|---|---|---|
listener |
Session.SessionListener | The SessionListener instance. |
setSignalListener(listener)
Sets a SignalListener object to monitor when signals are
sent in this session.
Parameters:
| Name | Type | Description |
|---|---|---|
listener |
Session.SignalListener | The SignalListener instance. |
setStreamCaptionsPropertiesListener(listener)
Sets a StreamCaptionsPropertiesListener object to monitor properties
of stream captions property.
Parameters:
| Name | Type | Description |
|---|---|---|
listener |
Session.StreamCaptionsPropertiesListener | The StreamCaptionsPropertiesListener instance. |
setStreamPropertiesListener(listener)
Sets a StreamPropertiesListener object to monitor properties
of streams in this session change. These include properties indicating whether
the stream has audio, whether it has video video, and its video dimensions.
Parameters:
| Name | Type | Description |
|---|---|---|
listener |
Session.StreamPropertiesListener | The StreamPropertiesListener instance. |
subscribe(subscriber)
Start receiving and rendering audio-video stream data for the specified subscriber.
Parameters:
| Name | Type | Description |
|---|---|---|
subscriber |
SubscriberKit | The subscriber bound to the stream to be received. |
unpublish(publisher)
Disconnects the Publisher from the session.
Parameters:
| Name | Type | Description |
|---|---|---|
publisher |
PublisherKit | The Publisher to unpublish. |
unsubscribe(subscriber)
Stops subscribing (receiving a stream) to a specified subscriber in the session.
Parameters:
| Name | Type | Description |
|---|---|---|
subscriber |
SubscriberKit | The Subscriber you want to stop subscribing to. |