com.opentok.android.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.
See Also: : - Session Creation - Token Creation
Nested Class Summary
Nested Classes
Modifier and Type
Class
Description
static interface
Session.ArchiveListener
Monitors when an archive recording of the session starts and stops.
static class
Session.Builder
static class
Session.Capabilities
Defines the value returned by the getCapabilities() method.
protected static class
Session.ConfigurableSessionOptions
static interface
Session.ConnectionListener
Monitors when other clients connect and disconnect to the session.
static interface
Session.MuteListener
Monitors when a moderator mutes streams in the session or disables the mute state in the session.
static interface
Session.ReconnectionListener
Monitors when an a client tries to automatically reconnect after losing its connection to an OpenTok session.
static interface
Session.SessionListener
Monitors state changes in a Session object.
static class
Session.SessionOptions
A base class for defining advanced session options with the
Session.Builder.sessionOptions(Session.SessionOptions sessionOptions) method.
static interface
Session.SessionOptionsProvider
Deprecated.
static interface
Session.SignalListener
Monitors when a signal is sent in the session.
static interface
Session.StreamCaptionsPropertiesListener
Monitors when caption properties of streams in the session change.
static interface
Session.StreamPropertiesListener
Monitors when properties of streams in the session change.
Field Summary
Fields
Modifier and Type
Field
Description
protected String
apiKey
protected URL
apiUrl
protected Session.ArchiveListener
archiveListener
protected Session.ConnectionListener
connectionListener
protected android.content.Context
context
protected Session.MuteListener
muteListener
protected Session.ReconnectionListener
reconnectionListener
protected String
sessionId
protected Session.SessionListener
sessionListener
protected Session.SignalListener
signalListener
protected Session.StreamCaptionsPropertiesListener
streamCaptionsPropertiesListener
protected Session.StreamPropertiesListener
streamPropertiesListener
Constructor Summary
Constructors
Modifier
Constructor
Description
protected
Session(Session.Builder builder)
Method Summary
All MethodsInstance MethodsConcrete Methods
Modifier and Type
Method
Description
void
connect(String token)
Connects to the OpenTok session provided in the Session constructor, using the provided authentication token.
void
disableForceMute()
Disables the active mute state of the session.
void
disconnect()
Disconnects from this session.
protected void
finalize()
Called by the garbage collector when it determines that there are no more references to the Session object.
void
forceDisconnect(Connection connection)
Forces a client to disconnect from the session.
void
forceMuteAll(Iterable<Stream> excludedStreams)
Forces all publishers in the session (except for those publishing excluded streams) to mute audio.
void
forceMuteStream(Stream stream)
Forces the publisher of a specified stream to mute its audio.
Session.Capabilities
getCapabilities()
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.
Connection
getConnection()
Returns the Connection corresponding to this client's connection
to this Session.
String
getSessionId()
Returns the Session ID passed in during instantiation.
protected void
onArchiveStarted(String id, String name)
Called when an archive of the session starts recording.
protected void
onArchiveStopped(String id)
Called when an archive of the session stops being recorded.
protected void
onConnected()
Invoked when the client connects to the OpenTok session.
protected void
onConnectionCreated(Connection connection)
Invoked when another client connects to the session.
protected void
onConnectionDestroyed(Connection connection)
Invoked when another client leaves the session.
protected void
onDisconnected()
Invoked when the client is no longer connected to the OpenTok session.
protected void
onError(OpentokError error)
Invoked when something goes wrong when connecting or connected to the session.
protected void
onMuteForced(MuteForcedInfo info)
Invoked when a moderator mutes streams in the session or disables the mute state in the session.
void
onPause()
Call this method when the app's activity pauses.
protected void
onReconnected()
Invoked when the local client has reconnected to the OpenTok session after its network connection was lost temporarily.
protected void
onReconnecting()
Invoked when the local client has lost its connection to an OpenTok session and is trying to reconnect.
void
onResume()
Call this method when the app's activity resumes.
protected void
onSignalReceived(String type, String data, Connection connection)
Called when a signal is received in the session.
protected void
onStreamDropped(Stream stream)
Invoked when another client stops publishing a stream to this OpenTok session.
protected void
onStreamHasAudioChanged(Stream stream, int hasAudio)
Called when a stream in the session changes between having audio and not having audio.
protected void
onStreamHasCaptionsChanged(Stream stream, int hasCaptions)
Called when a stream in the session changes between having captions and not having captions.
protected void
onStreamHasVideoChanged(Stream stream, int hasVideo)
Called when a stream in the session changes between having video and not having video.
protected void
onStreamReceived(Stream stream)
Invoked when a there is a new stream published by another client in this OpenTok session.
protected void
onStreamVideoDimensionsChanged(Stream stream, int width, int height)
Called when the video dimensions of a stream in the session change.
protected void
onStreamVideoTypeChanged(Stream stream, int videoType)
Called when the video type of a stream in the session change.
void
publish(PublisherKit publisher)
Starts a Publisher streaming to the session.
String
reportIssue()
Report that your app experienced an issue.
void
sendSignal(String type, String data)
Sends a signal to all clients in a session.
void
sendSignal(String type, String data, boolean retryAfterReconnect)
Sends a signal to all clients in a session.
void
sendSignal(String type, String data, Connection connection)
Sends a signal to a specific client in a session.
void
sendSignal(String type, String data, Connection connection, boolean retryAfterReconnect)
Sends a signal to a specific client in a session.This version of the method includes
a retryAfterReconnect parameter.
void
setArchiveListener(Session.ArchiveListener listener)
Sets an Session.ArchiveListener object to monitor when an archive recording
starts or stops in this session.
void
setConnectionListener(Session.ConnectionListener listener)
Sets a Session.ConnectionListener object to monitor when other clients
connect and disconnect from this session.
void
setEncryptionSecret(String secret)
Sets the end-to-end encryption secret used by all publishers and subscribers.
void
setMuteListener(Session.MuteListener listener)
Sets a Session.MuteListener object to monitor when mute forced is
sent in this session.
void
setReconnectionListener(Session.ReconnectionListener listener)
Sets a Session.ReconnectionListener object to be notified when the client is
attempting to reconnect or reconnected to an OpenTok session.
void
setSessionListener(Session.SessionListener listener)
Sets a Session.SessionListener object to monitor state changes for this
Session object.
void
setSignalListener(Session.SignalListener listener)
Sets a Session.SignalListener object to monitor when signals are
sent in this session.
void
setStreamCaptionsPropertiesListener(Session.StreamCaptionsPropertiesListener listener)
Sets a Session.StreamCaptionsPropertiesListener object to monitor properties
of stream captions property.
void
setStreamPropertiesListener(Session.StreamPropertiesListener listener)
Sets a Session.StreamPropertiesListener object to monitor properties
of streams in this session change.
void
subscribe(SubscriberKit subscriber)
Start receiving and rendering audio-video stream data for the specified subscriber.
void
unpublish(PublisherKit publisher)
Disconnects the Publisher from the session.
void
unsubscribe(SubscriberKit subscriber)
Stops subscribing (receiving a stream) to a specified subscriber in the session.
Methods inherited from class java.util.Observable
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Field Details
sessionListener
protected Session.SessionListener sessionListener
connectionListener
protected Session.ConnectionListener connectionListener
streamPropertiesListener
protected Session.StreamPropertiesListener streamPropertiesListener
streamCaptionsPropertiesListener
protected Session.StreamCaptionsPropertiesListener streamCaptionsPropertiesListener
signalListener
protected Session.SignalListener signalListener
archiveListener
protected Session.ArchiveListener archiveListener
reconnectionListener
protected Session.ReconnectionListener reconnectionListener
muteListener
protected Session.MuteListener muteListener
context
protected android.content.Context context
apiKey
protected String apiKey
sessionId
protected String sessionId
apiUrl
protected URL apiUrl
Constructor Details
Session
protected Session(Session.Builder builder) throws Exception
Throws:
: Exception
Method Details
getConnection
public Connection getConnection()
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.
Returns: : The OpenTok Session ID for this instance.
See Also:
: - Session.SessionListener.onConnected(Session session)
- Session.SessionListener.onStreamReceived(Session session, Stream stream)
- Stream.getConnection()
getSessionId
public String getSessionId()
Returns the Session ID passed in during instantiation.
Returns: : The OpenTok Session ID for this instance.
setSessionListener
public void setSessionListener(Session.SessionListener listener)
Sets a Session.SessionListener object to monitor state changes for this
Session object.
Parameters:
: listener - The Session.SessionListener instance.
setConnectionListener
public void setConnectionListener(Session.ConnectionListener listener)
Sets a Session.ConnectionListener object to monitor when other clients
connect and disconnect from this session.
Parameters:
: listener - The Session.ConnectionListener instance.
setStreamPropertiesListener
public void setStreamPropertiesListener(Session.StreamPropertiesListener listener)
Sets a Session.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:
: listener - The Session.StreamPropertiesListener instance.
setStreamCaptionsPropertiesListener
public void setStreamCaptionsPropertiesListener(Session.StreamCaptionsPropertiesListener listener)
Sets a Session.StreamCaptionsPropertiesListener object to monitor properties
of stream captions property.
Parameters:
: listener - The Session.StreamCaptionsPropertiesListener instance.
setSignalListener
public void setSignalListener(Session.SignalListener listener)
Sets a Session.SignalListener object to monitor when signals are
sent in this session.
Parameters:
: listener - The Session.SignalListener instance.
setArchiveListener
public void setArchiveListener(Session.ArchiveListener listener)
Sets an Session.ArchiveListener object to monitor when an archive recording
starts or stops in this session.
Parameters:
: listener - The Session.ArchiveListener instance.
setReconnectionListener
public void setReconnectionListener(Session.ReconnectionListener listener)
Sets a Session.ReconnectionListener object to be notified when the client is
attempting to reconnect or reconnected to an OpenTok session.
Parameters:
: listener - The Session.ReconnectionListener instance.
setMuteListener
public void setMuteListener(Session.MuteListener listener)
Sets a Session.MuteListener object to monitor when mute forced is
sent in this session.
Parameters:
: listener - The Session.MuteListener instance.
connect
public void connect(String 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:
: token - The token for the user. See Token
Creation Overview.
disconnect
public void disconnect()
Disconnects from this session. All Subscriber and Publisher instances
will be disconnected. As a best practice, before calling this method,
call the unpublish(PublisherKit) method for all publishers
and wait for the PublisherKit.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.
onPause
public void 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 onResume() method.
onResume
public void 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 onPause() method are reacquired when you call
Session.onResume().
publish
public void publish(PublisherKit publisher)
Starts a Publisher streaming to the session.
Parameters:
: publisher - The Publisher that you want to stream to the session.
unpublish
public void unpublish(PublisherKit publisher)
Disconnects the Publisher from the session.
Parameters:
: publisher - The Publisher to unpublish.
subscribe
public void subscribe(SubscriberKit subscriber)
Start receiving and rendering audio-video stream data for the specified subscriber.
Parameters:
: subscriber - The subscriber bound to the stream to be received.
unsubscribe
public void unsubscribe(SubscriberKit subscriber)
Stops subscribing (receiving a stream) to a specified subscriber in the session.
Parameters:
: subscriber - The Subscriber you want to stop subscribing to.
sendSignal
public void sendSignal(String type, String data)
Sends a signal to all clients in a session.
Parameters:
: type - 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 - The data to send. The limit to the size of data is 8kB.
See Also:
: - 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
public void sendSignal(String type, String data, boolean retryAfterReconnect)
Sends a signal to all clients in a session. This version of the method includes
a retryAfterReconnect parameter.
Parameters:
: type - 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 - The data to send. The limit to the size of data is 8kB.
: retryAfterReconnect - 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 Also:
: - sendSignal(String type, String data)
- Session.ReconnectionListener.onReconnecting(Session session)
- Session.SignalListener.onSignalReceived(Session session, String type, String data, Connection connection)
sendSignal
public void sendSignal(String type, String data, Connection connection)
Sends a signal to a specific client in a session.
Parameters:
: type - 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 - The data to send. The limit to the size of data is 8kB.
: 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 Also:
: - 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
public void sendSignal(String type, String data, Connection connection, boolean retryAfterReconnect)
Sends a signal to a specific client in a session.This version of the method includes
a retryAfterReconnect parameter.
Parameters:
: type - 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 - The data to send. The limit to the size of data is 8kB.
: 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 - 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 Also:
: - 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)
getCapabilities
public Session.Capabilities getCapabilities()
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.
reportIssue
public String reportIssue()
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.
forceDisconnect
public void forceDisconnect(@NonNull Connection connection)
Forces a client to disconnect from the session.
While you can use 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),
onConnectionDestroyed(Connection)
and PublisherKit.onStreamDestroyed(Stream)
callbacks are dispatched in the same way as they would be if the
connection had terminated itself using disconnect().
Parameters:
: connection - The connection to disconnect.
forceMuteStream
public void forceMuteStream(@NonNull Stream stream)
Forces the publisher of a specified stream to mute its audio.
Check the canForceMute property of the object returned by calling
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:
: stream - The object that represent the stream for the force mute
request. This includes the stream that should be muted.
See Also:
: - getCapabilities()
- forceMuteAll(Iterable)
- PublisherKit.onMuteForced()
- Muting the audio
of streams in a session
forceMuteAll
public void forceMuteAll(@Nullable Iterable<Stream> 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
disableForceMute() method. After you call the 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
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:
: excludedStreams - The object that represent the streams to be excluded from the force
mute request. This includes the stream that should not be muted.
See Also:
: - Session.MuteListener.onMuteForced(Session session, MuteForcedInfo info)
- getCapabilities()
- disableForceMute()
- forceMuteStream(Stream stream)
- Session.MuteListener.onMuteForced(Session session, MuteForcedInfo info)
- PublisherKit.onMuteForced()
- Muting the audio
of streams in a session
disableForceMute
public void 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 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
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 Also:
: - Session.MuteListener.onMuteForced(Session session, MuteForcedInfo info)
- getCapabilities()
- forceMuteAll(Iterable)
- Muting the audio
of streams in a session
setEncryptionSecret
public void setEncryptionSecret(String secret)
Sets the end-to-end encryption secret used by all publishers and subscribers.
See the End-to-end encryption developer guide.
Parameters:
: secret - Value of the encryption secret.
onArchiveStarted
protected void onArchiveStarted(String id, String 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:
: id - The unique ID of the archive.
: name - The name of the archive (if one was provided when the archive was created).
onArchiveStopped
protected void onArchiveStopped(String 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:
: id - The unique ID of the archive.
onStreamHasAudioChanged
protected void onStreamHasAudioChanged(Stream stream, int 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:
: stream - The stream.
: hasAudio - Whether the stream has audio (true) or not (
false).
onStreamHasCaptionsChanged
protected void onStreamHasCaptionsChanged(Stream stream, int 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:
: stream - The stream.
: hasCaptions - Whether the stream has captions (true) or not (
false).
onStreamHasVideoChanged
protected void onStreamHasVideoChanged(Stream stream, int 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:
: stream - The stream.
: hasVideo - Whether the stream has video (true) or not (
false).
onStreamVideoDimensionsChanged
protected void onStreamVideoDimensionsChanged(Stream stream, int width, int 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:
: stream - The stream.
: width - The new width of the stream, in pixels.
: height - The new height of the stream, in pixels.
onStreamVideoTypeChanged
protected void onStreamVideoTypeChanged(Stream stream, int 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:
: stream - The stream.
: videoType - The new video type of the stream.
onConnectionCreated
protected void onConnectionCreated(Connection 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:
: connection - The new connection in the session.
onConnectionDestroyed
protected void onConnectionDestroyed(Connection 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:
: connection - The connection that left the session the session.
onSignalReceived
protected void onSignalReceived(String type, String data, Connection 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:
: type - The type string of the signal.
: data - The signal data.
: connection - The connection identifying the client that sent the
message. This value can be null.
onReconnecting
protected void 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 Also:
: - onReconnected()
onReconnected
protected void 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
sendSignal(String type, String data) method are sent when the client
reconnects. To prevent any signals initiated while disconnected from being sent,
use the 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 Also:
: - onReconnecting()
onConnected
protected void 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.
onDisconnected
protected void 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.
onStreamReceived
protected void onStreamReceived(Stream 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:
: stream - A Stream object representing the new stream, which can be
used to create a Subscriber.
onStreamDropped
protected void onStreamDropped(Stream 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:
: stream - A Stream object representing the dropped stream, which can
be used to identify a Subscriber.
onError
protected void onError(OpentokError 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:
: error - An error describing the cause for error.
onMuteForced
protected void onMuteForced(MuteForcedInfo 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:
: info - 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 Also:
: - forceMuteAll(Iterable)
- disableForceMute()
- onMuteForced(MuteForcedInfo)
- PublisherKit.onMuteForced()
- Muting the audio
of streams in a session
finalize
protected void finalize() throws Throwable
Called by the garbage collector when it determines that there are no more references to the Session object.
Overrides:
: finalize in class Object
Throws:
: Throwable