Class Session
- java.lang.Object
-
- java.util.Observable
-
- com.opentok.android.Session
-
public class Session extends java.util.ObservableRepresents 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 interfaceSession.ArchiveListenerMonitors when an archive recording of the session starts and stops.static classSession.Builderstatic classSession.CapabilitiesDefines the value returned by thegetCapabilities()method.protected static classSession.ConfigurableSessionOptionsstatic interfaceSession.ConnectionListenerMonitors when other clients connect and disconnect to the session.static interfaceSession.MuteListenerMonitors when a moderator mutes streams in the session or disables the mute state in the session.static interfaceSession.ReconnectionListenerMonitors when an a client tries to automatically reconnect after losing its connection to an OpenTok session.static interfaceSession.SessionListenerMonitors state changes in aSessionobject.static classSession.SessionOptionsA base class for defining advanced session options with theSession.Builder.sessionOptions(Session.SessionOptions sessionOptions)method.static interfaceSession.SessionOptionsProviderDeprecated.static interfaceSession.SignalListenerMonitors when a signal is sent in the session.static interfaceSession.StreamCaptionsPropertiesListenerMonitors when caption properties of streams in the session change.static interfaceSession.StreamPropertiesListenerMonitors when properties of streams in the session change.
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.StringapiKeyprotected java.net.URLapiUrlprotected Session.ArchiveListenerarchiveListenerprotected Session.ConnectionListenerconnectionListenerprotected android.content.Contextcontextprotected Session.MuteListenermuteListenerprotected Session.ReconnectionListenerreconnectionListenerprotected java.lang.StringsessionIdprotected Session.SessionListenersessionListenerprotected Session.SignalListenersignalListenerprotected Session.StreamCaptionsPropertiesListenerstreamCaptionsPropertiesListenerprotected Session.StreamPropertiesListenerstreamPropertiesListener
-
Constructor Summary
Constructors Modifier Constructor Description Session(android.content.Context context, java.lang.String apiKey, java.lang.String sessionId)Deprecated.protectedSession(android.content.Context context, java.lang.String apiKey, java.lang.String sessionId, boolean connectionEventsSuppressed, Session.SessionOptions sessionOptions, Session.Builder.TransportPolicy routing, Session.Builder.IncludeServers turnConfig, Session.Builder.IceServer[] iceServers, java.net.URL apiUrl, boolean ipWhitelist, java.lang.String proxyUrl, boolean singlePeerConnection)Creates a new Session object.Session(android.content.Context context, java.lang.String apiKey, java.lang.String sessionId, Session.SessionOptions sessionOptions)Deprecated.Session(android.content.Context context, java.lang.String apiKey, java.lang.String sessionId, Session.SessionOptionsProvider optionsProvider)Deprecated.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidconnect(java.lang.String token)Connects to the OpenTok session provided in the Session constructor, using the provided authentication token.voiddisableForceMute()Disables the active mute state of the session.voiddisconnect()Disconnects from this session.protected voidfinalize()Called by the garbage collector when it determines that there are no more references to the Session object.voidforceMuteAll(java.lang.Iterable<Stream> excludedStreams)Forces all publishers in the session (except for those publishing excluded streams) to mute audio.voidforceMuteStream(Stream stream)Forces the publisher of a specified stream to mute its audio.Session.CapabilitiesgetCapabilities()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.ConnectiongetConnection()Returns theConnectioncorresponding to this client's connection to this Session.java.lang.StringgetSessionId()Returns the Session ID passed in during instantiation.protected voidonArchiveStarted(java.lang.String id, java.lang.String name)Called when an archive of the session starts recording.protected voidonArchiveStopped(java.lang.String id)Called when an archive of the session stops being recorded.protected voidonConnected()Invoked when the client connects to the OpenTok session.protected voidonConnectionCreated(Connection connection)Invoked when another client connects to the session.protected voidonConnectionDestroyed(Connection connection)Invoked when another client leaves the session.protected voidonDisconnected()Invoked when the client is no longer connected to the OpenTok session.protected voidonError(OpentokError error)Invoked when something goes wrong when connecting or connected to the session.protected voidonMuteForced(MuteForcedInfo info)Invoked when a moderator mutes streams in the session or disables the mute state in the session.voidonPause()Call this method when the app's activity pauses.protected voidonReconnected()Invoked when the local client has reconnected to the OpenTok session after its network connection was lost temporarily.protected voidonReconnecting()Invoked when the local client has lost its connection to an OpenTok session and is trying to reconnect.voidonResume()Call this method when the app's activity resumes.protected voidonSignalReceived(java.lang.String type, java.lang.String data, Connection connection)Called when a signal is received in the session.protected voidonStreamDropped(Stream stream)Invoked when another client stops publishing a stream to this OpenTok session.protected voidonStreamHasAudioChanged(Stream stream, int hasAudio)Called when a stream in the session changes between having audio and not having audio.protected voidonStreamHasCaptionsChanged(Stream stream, int hasCaptions)Called when a stream in the session changes between having captions and not having captions.protected voidonStreamHasVideoChanged(Stream stream, int hasVideo)Called when a stream in the session changes between having video and not having video.protected voidonStreamReceived(Stream stream)Invoked when a there is a new stream published by another client in this OpenTok session.protected voidonStreamVideoDimensionsChanged(Stream stream, int width, int height)Called when the video dimensions of a stream in the session change.protected voidonStreamVideoTypeChanged(Stream stream, int videoType)Called when the video type of a stream in the session change.voidpublish(PublisherKit publisher)Starts a Publisher streaming to the session.java.lang.StringreportIssue()Report that your app experienced an issue.voidsendSignal(java.lang.String type, java.lang.String data)Sends a signal to all clients in a session.voidsendSignal(java.lang.String type, java.lang.String data, boolean retryAfterReconnect)Sends a signal to all clients in a session.voidsendSignal(java.lang.String type, java.lang.String data, Connection connection)Sends a signal to a specific client in a session.voidsendSignal(java.lang.String type, java.lang.String data, Connection connection, boolean retryAfterReconnect)Sends a signal to a specific client in a session.This version of the method includes aretryAfterReconnectparameter.voidsetArchiveListener(Session.ArchiveListener listener)Sets anSession.ArchiveListenerobject to monitor when an archive recording starts or stops in this session.voidsetConnectionListener(Session.ConnectionListener listener)Sets aSession.ConnectionListenerobject to monitor when other clients connect and disconnect from this session.voidsetEncryptionSecret(java.lang.String secret)Sets the end-to-end encryption secret used by all publishers and subscribers.voidsetMuteListener(Session.MuteListener listener)Sets aSession.MuteListenerobject to monitor when mute forced is sent in this session.voidsetReconnectionListener(Session.ReconnectionListener listener)Sets aSession.ReconnectionListenerobject to be notified when the client is attempting to reconnect or reconnected to an OpenTok session.voidsetSessionListener(Session.SessionListener listener)Sets aSession.SessionListenerobject to monitor state changes for this Session object.voidsetSignalListener(Session.SignalListener listener)Sets aSession.SignalListenerobject to monitor when signals are sent in this session.voidsetStreamCaptionsPropertiesListener(Session.StreamCaptionsPropertiesListener listener)Sets aSession.StreamCaptionsPropertiesListenerobject to monitor properties of stream captions property.voidsetStreamPropertiesListener(Session.StreamPropertiesListener listener)Sets aSession.StreamPropertiesListenerobject to monitor properties of streams in this session change.voidsubscribe(SubscriberKit subscriber)Start receiving and rendering audio-video stream data for the specified subscriber.voidunpublish(PublisherKit publisher)Disconnects the Publisher from the session.voidunsubscribe(SubscriberKit subscriber)Stops subscribing (receiving a stream) to a specified subscriber in the session.
-
-
-
Field Detail
-
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 java.lang.String apiKey
-
sessionId
protected java.lang.String sessionId
-
apiUrl
protected java.net.URL apiUrl
-
-
Constructor Detail
-
Session
@Deprecated public Session(android.content.Context context, java.lang.String apiKey, java.lang.String sessionId) throws java.lang.ExceptionDeprecated.Create a Session instance. This constructor is deprecated. Use theSession.Builderinstead.- Parameters:
context- The Android application context associated with this process.apiKey- Your OpenTok API key. See your Vonage Video API account page. Important: If you are using the Video API with a Vonage application (instead of an OpenTok project), pass in the application ID (not an OpenTok API key) for this parameter.sessionId- The OpenTok session ID this instance should connect to. For test purposes, you can generate test session by logging into your Vonage Video API account. Use the OpenTok server-side SDKs to generate session IDs in your shipping app.- Throws:
java.lang.Exception- See Also:
setSessionListener(com.opentok.android.Session.SessionListener)
-
Session
@Deprecated public Session(android.content.Context context, java.lang.String apiKey, java.lang.String sessionId, Session.SessionOptionsProvider optionsProvider) throws java.lang.ExceptionDeprecated.Use this constructor to create a Session instance and use a SessionOptionsProvider object to define hardware video decoding options.This constructor is deprecated. Use the
Session.Builderinstead and call theSession.Builder.sessionOptions(Session.SessionOptions sessionOptions)method.- Parameters:
context- The Android application context associated with this process.apiKey- Your OpenTok API key. See your Vonage Video API account page.sessionId- The OpenTok session ID this instance should connect to. For test purposes, you can generate test session by logging onto your Vonage Video API account page. Use the OpenTok server-side SDKs to generate session IDs in your shipping app.optionsProvider- The object that implements the SessionOptionsProvider interface.- Throws:
java.lang.Exception- See Also:
setSessionListener(com.opentok.android.Session.SessionListener)
-
Session
@Deprecated public Session(android.content.Context context, java.lang.String apiKey, java.lang.String sessionId, Session.SessionOptions sessionOptions) throws java.lang.ExceptionDeprecated.Use this constructor to create a Session instance and use a SessionOptions object to define hardware video decoding options. This constructor is deprecated. Use theSession.Builderinstead.- Parameters:
context- The Android application context associated with this process.apiKey- Your OpenTok API key. See your Vonage Video API account page.sessionId- The OpenTok session ID this instance should connect to. For test purposes, you can generate test session by logging onto your Vonage Video API account page. Use the OpenTok server-side SDKs to generate session IDs in your shipping app.sessionOptions- The object that inherits from SessionOptions object.- Throws:
java.lang.Exception- See Also:
setSessionListener(com.opentok.android.Session.SessionListener)
-
Session
protected Session(android.content.Context context, java.lang.String apiKey, java.lang.String sessionId, boolean connectionEventsSuppressed, Session.SessionOptions sessionOptions, Session.Builder.TransportPolicy routing, Session.Builder.IncludeServers turnConfig, Session.Builder.IceServer[] iceServers, java.net.URL apiUrl, boolean ipWhitelist, java.lang.String proxyUrl, boolean singlePeerConnection) throws java.lang.ExceptionCreates a new Session object. If you extend theSessionclass, you can call this constructor from the child class.- Parameters:
context- The Android application context associated with this process.apiKey- Your OpenTok API key. See your Vonage Video API account page. Important: If you are using the Video API with a Vonage application (instead of an OpenTok project), pass in the application ID (not an OpenTok API key) for this parameter.sessionId- The OpenTok session ID this instance should connect to. For test purposes, you can generate test session by logging onto your Vonage Video API account page. Use the OpenTok server-side SDKs to generate session IDs in your shipping app.connectionEventsSuppressed- Prevent connection events (such asSession.ConnectionListener.onConnectionCreated(Session session, Connection connection)) from being dispatchedsessionOptions- The object that inherits from SessionOptions object.routing- This is part of the configurable TURN feature.turnConfig- This is part of the configurable TURN feature.iceServers- This is part of the configurable TURN feature.apiUrl- This is not used.ipWhitelist- Set this totrueif allowed IP list feature is enabled for your project. (This is available as an add-on feature.)proxyUrl- Set this to the URL of the IP proxy server. This is available as an add-on feature. See the OpenTok pricing page and the IP proxy developer guide.singlePeerConnection- Single Peer Connection (SPC) is a feature that encapsulates all subscriber connections to a single peer connection. The benefits of enabling SPC include reduced OS resource consumption, improved rate control, and, in case of mobile native devices, support for larger sessions. SPC is disabled by default. When disabled, the session will use Multiple Peer Connection (MPC), where a separate peer connection is established between each endpoint.- Throws:
java.lang.Exception
-
-
Method Detail
-
getConnection
public Connection getConnection()
Returns theConnectioncorresponding 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 theStream.getConnection()method with the Connection object returned bySesssion.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 java.lang.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 aSession.SessionListenerobject to monitor state changes for this Session object.- Parameters:
listener- TheSession.SessionListenerinstance.
-
setConnectionListener
public void setConnectionListener(Session.ConnectionListener listener)
Sets aSession.ConnectionListenerobject to monitor when other clients connect and disconnect from this session.- Parameters:
listener- TheSession.ConnectionListenerinstance.
-
setStreamPropertiesListener
public void setStreamPropertiesListener(Session.StreamPropertiesListener listener)
Sets aSession.StreamPropertiesListenerobject 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- TheSession.StreamPropertiesListenerinstance.
-
setStreamCaptionsPropertiesListener
public void setStreamCaptionsPropertiesListener(Session.StreamCaptionsPropertiesListener listener)
Sets aSession.StreamCaptionsPropertiesListenerobject to monitor properties of stream captions property.- Parameters:
listener- TheSession.StreamCaptionsPropertiesListenerinstance.
-
setSignalListener
public void setSignalListener(Session.SignalListener listener)
Sets aSession.SignalListenerobject to monitor when signals are sent in this session.- Parameters:
listener- TheSession.SignalListenerinstance.
-
setArchiveListener
public void setArchiveListener(Session.ArchiveListener listener)
Sets anSession.ArchiveListenerobject to monitor when an archive recording starts or stops in this session.- Parameters:
listener- TheSession.ArchiveListenerinstance.
-
setReconnectionListener
public void setReconnectionListener(Session.ReconnectionListener listener)
Sets aSession.ReconnectionListenerobject to be notified when the client is attempting to reconnect or reconnected to an OpenTok session.- Parameters:
listener- TheSession.ReconnectionListenerinstance.
-
setMuteListener
public void setMuteListener(Session.MuteListener listener)
Sets aSession.MuteListenerobject to monitor when mute forced is sent in this session.- Parameters:
listener- TheSession.MuteListenerinstance.
-
connect
public void connect(java.lang.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 theunpublish(PublisherKit)method for all publishers and wait for thePublisherKit.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 callSession.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 Subcriber you want to stop subscribing to.
-
sendSignal
public void sendSignal(java.lang.String type, java.lang.String data)Sends a signal to all clients in a session.- Parameters:
type- The type of the signal. The type is also set in theSession.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(java.lang.String type, java.lang.String data, boolean retryAfterReconnect)Sends a signal to all clients in a session. This version of the method includes aretryAfterReconnectparameter.- Parameters:
type- The type of the signal. The type is also set in theSession.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 theSession.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 theretryAfterReconnectparameter tofalse. (The default value istrue.)- 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(java.lang.String type, java.lang.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 theSession.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. (SeeSession.ConnectionListener.onConnectionCreated(Session session, Connection connection)andConnection.- 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(java.lang.String type, java.lang.String data, Connection connection, boolean retryAfterReconnect)Sends a signal to a specific client in a session.This version of the method includes aretryAfterReconnectparameter.- Parameters:
type- The type of the signal. The type is also set in theSession.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. (SeeSession.ConnectionListener.onConnectionCreated(Session session, Connection connection)andConnection.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 theSession.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 theretryAfterReconnectparameter tofalse. (The default value istrue.)- 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 returnsnulluntil you have connected to a session and theSession.SessionListener.onConnected(Session session)method has been called.
-
reportIssue
public java.lang.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.
-
forceMuteStream
public void forceMuteStream(@NonNull Stream stream)Forces the publisher of a specified stream to mute its audio.Check the
canForceMuteproperty of the object returned by callinggetCapabilities()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 java.lang.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 thedisableForceMute()method. After you call thedisableForceMute()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 thegetActive()method of theinfoobject returningtrue.Check the
canForceMuteproperty of the object returned by callinggetCapabilities()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 thedisableForceMute()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 thegetActive()method of theinfoobject returningfalse.Check the
canForceMuteproperty of the object returned by callinggetCapabilities()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).
-
setEncryptionSecret
public void setEncryptionSecret(java.lang.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(java.lang.String id, java.lang.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(java.lang.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, theSession.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, theSession.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(java.lang.String type, java.lang.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 benull.
-
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, theSession.ReconnectionListener.onReconnected(Session session)method is called. Otherwise, if the client cannot reconnect, theSession.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, theSession.ReconnectionListener.onReconnecting(Session session)method is called, prior to theSession.ReconnectionListener.onReconnected(Session session)method. If the client cannot reconnect to the session, theSession.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 thesendSignal(String type, String data, boolean retryAfterReconnect)method to send the signal, and set theretryAfterReconnectparameter tofalse. (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 thegetActivemethod 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 java.lang.ThrowableCalled by the garbage collector when it determines that there are no more references to the Session object.- Overrides:
finalizein classjava.lang.Object- Throws:
java.lang.Throwable
-
-