Represents an Vonage Video API session in which the client is participating. More...
Inherits IDisposable.
Classes | |
class | ArchiveStartedEventArgs |
Defines arguments for the ArchiveStarted event. More... | |
class | ArchiveStoppedEventArgs |
Defines arguments for the ArchiveStopped event. More... | |
class | Builder |
Used to create a Session instance. More... | |
class | ConnectionEventArgs |
Defines arguments for the ConnectionCreated and ConnectionDroppedevents. More... | |
class | ErrorEventArgs |
Defines arguments for the Error event. More... | |
class | MuteForcedEventArgs |
Defines arguments for the MuteForced event. More... | |
class | SignalEventArgs |
Defines arguments for the Session.Signal event. More... | |
class | StreamEventArgs |
Defines arguments for the StreamReceived and StreamDropped events. More... |
Public Member Functions | |
Session (Context context, string apiKey, string sessionId, bool connectionEventsSuppressed=false, Uri apiUrl=null, bool ipWhitelist=false, Uri proxyUrl=null, IceConfig iceConfig=null, bool singlePeerConnection=false) | |
Creates a Session instance. More... | |
void | Dispose () |
Disposes of the Session object's resources. More... | |
void | Connect (string token) |
Connects to the Vonage Video API session provided in the Session constructor, using the provided authentication token. More... | |
void | Disconnect () |
Disconnects from this session. All Subscriber and Publisher instances will be disconnected. More... | |
void | SendSignal (string type, string data, Connection connection=null, bool retryAfterReconnect=true) |
Sends a signal to all clients in the session. More... | |
void | Subscribe (Subscriber subscriber) |
Start receiving and rendering audio-video stream data for the specified subscriber. More... | |
void | Unsubscribe (Subscriber subscriber) |
Stops subscribing (receiving a stream) to a specified subscriber in the session. More... | |
void | Publish (Publisher publisher) |
Starts a Publisher streaming to the session. More... | |
void | Unpublish (Publisher publisher) |
Disconnects the Publisher from the session. More... | |
void | ForceMuteAll (IEnumerable< Stream > excludedStreams=null) |
Forces all publishers in the session (except for those publishing excluded streams) to mute audio. More... | |
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. More... | |
void | ForceMuteStream (Stream stream) |
Forces the publisher of a specified stream to mute its audio. More... | |
void | SetEncryptionSecret (string secret) |
Sets the end-to-end encryption secret used by all publishers and subscribers. More... |
Protected Member Functions | |
virtual void | Dispose (bool disposing) |
Properties | |
Connection | Connection [get] |
Returns the Connection corresponding to this client's connection to this Session. More... | |
Capabilities | Capabilities [get] |
Whether the client can only subscribe to streams, or both publish and subscribe to streams, based on the role assigned to the token used to connect to the session. More... |
Events | |
EventHandler | Connected |
Sent when the client connects to the Vonage Video API session. More... | |
EventHandler | Disconnected |
Sent when the client disconnects from the Vonage Video API session. More... | |
EventHandler< ConnectionEventArgs > | ConnectionCreated |
Sent when another client connects to the session. More... | |
EventHandler< ConnectionEventArgs > | ConnectionDropped |
Sent when another client leaves the session. More... | |
EventHandler< StreamEventArgs > | StreamReceived |
Sent when a there is a new stream published by another client in this Vonage Video API session. More... | |
EventHandler< StreamEventArgs > | StreamDropped |
Sent when another client stops publishing a stream to this Vonage Video API session. More... | |
EventHandler< ErrorEventArgs > | Error |
Sent when something goes wrong when connecting or connected to the session. More... | |
EventHandler< SignalEventArgs > | Signal |
Called when a signal is received in the session. More... | |
EventHandler< StreamEventArgs > | StreamHasCaptionsChanged |
Called when a stream in the session changes between having captions and not having captions. More... | |
EventHandler< StreamEventArgs > | StreamHasAudioChanged |
Called when a stream in the session changes between having audio and not having audio. The StreamEventArgs.Stream object represents a snapshot of stream at the time of the callback. More... | |
EventHandler< StreamEventArgs > | StreamHasVideoChanged |
Called when a stream in the session changes between having video and not having video. The StreamEventArgs.Stream object represents a snapshot of stream at the time of the callback. More... | |
EventHandler< StreamEventArgs > | StreamDimensionsChanged |
Called when the video dimensions of a stream in the session change. The StreamEventArgs.Stream object represents a snapshot of stream at the time of the callback. More... | |
EventHandler | ReconnectionStart |
Sent when the local client has lost its connection to an Vonage Video API session and is trying to reconnect. This results from a loss in network connectivity. More... | |
EventHandler | ReconnectionSuccess |
Invoked when the local client has reconnected to the Vonage Video API session after its network connection was lost temporarily. More... | |
EventHandler< ArchiveStartedEventArgs > | ArchiveStarted |
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. More... | |
EventHandler< ArchiveStoppedEventArgs > | ArchiveStopped |
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. More... | |
EventHandler< MuteForcedEventArgs > | MuteForced |
Called when a moderator forces clients publishing streams to the session to mute audio (the IsActive property of the MuteForcedEventArgs object is set to true ), or when a moderator disables the mute audio state in the session (the IsActive property of the MuteForcedEventArgs object is set to false ). More... |
Represents an Vonage Video API session in which the client is participating.
The first step in using the Vonage Video API Windows SDK is to instantiate a Session object using the Session.Builder class.
The Session class implements the System.IDisposable interface. Be sure to call the Dispose() method of the Session object to release its resources when you no longer need the object (for example, when the app or window is closing).
See also Session Creation and Token Creation.
OpenTok.Session.Session | ( | Context | context, |
string | apiKey, | ||
string | sessionId, | ||
bool | connectionEventsSuppressed = false , |
||
Uri | apiUrl = null , |
||
bool | ipWhitelist = false , |
||
Uri | proxyUrl = null , |
||
IceConfig | iceConfig = null , |
||
bool | singlePeerConnection = false |
||
) |
Creates a Session instance.
context | The Content object used to manage resources for the Session. |
apiKey | Your Vonage Video API key. See your Vonage Video API account page. |
sessionId | The Vonage Video API 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 SDKs to generate session IDs in your shipping application. |
connectionEventsSuppressed | Prevent connection events (such as ConnectionCreated from being dispatched. The default value is false . |
apiUrl | This parameter is deprecated. (Its value is ignored.) |
ipWhitelist | Set this to true if the allowed IP list feature is enabled for your project. (This is available as an add-on feature. The default value is false . |
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. |
iceConfig | This parameter is used by the configurable TURN feature. |
.
void OpenTok.Session.Connect | ( | string | token | ) |
Connects to the Vonage Video API session provided in the Session constructor, using the provided authentication token.
When the session connects, the Session object sends the Connected event.
If the session fails to connect, the Session object sends the Error event.
token | The token for the user. See Token Creation Overview. |
void OpenTok.Session.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 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 object in each client connected to the session to send the MuteForced event, with the IsActive
property of the MuteForcedEventArgs object to be set to false
.
Check the CanForceMute
property of the Session.Capabilities object 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 overview).
See Muting the audio of streams in a session.
void OpenTok.Session.Disconnect | ( | ) |
Disconnects from this session. All Subscriber and Publisher instances will be disconnected.
As a best practice, before calling this method, call the Unpublish(Publisher) method for all publishers and wait for the Publisher.StreamDestroyed event. 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 sends the Disconnected event.
void OpenTok.Session.Dispose | ( | ) |
Disposes of the Session object's resources.
void OpenTok.Session.ForceMuteAll | ( | IEnumerable< Stream > | excludedStreams = null | ) |
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 object in each client connected to the session to send the MuteForced event, with the IsActive
property of the MuteForcedEventArgs object to be set to true
.
Check the CanForceMute
property of the Session.Capabilities object 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 overview).
See Muting the audio of streams in a session.
excludedStreams | Streams to be excluded from the mute request. Set this to null (or do not set this parameter) to mute all streams in the session (including those published by the local client). |
void OpenTok.Session.ForceMuteStream | ( | Stream | stream | ) |
Forces the publisher of a specified stream to mute its audio.
Check the CanForceMute
property of the Session.Capabilities object 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 overview).
See Muting the audio of streams in a session.
stream | The stream to be muted. |
void OpenTok.Session.Publish | ( | Publisher | publisher | ) |
void OpenTok.Session.SendSignal | ( | string | type, |
string | data, | ||
Connection | connection = null , |
||
bool | retryAfterReconnect = true |
||
) |
Sends a signal to all clients in the session.
type | The type of the signal. The type is set in the SignalEventArgs.Type argument of the Signal event listener. |
data | The data to send. The limit to the size of data is 8kB. The type is set in the SignalEventArgs.Data argument of the Signal event listener. |
connection | |
retryAfterReconnect |
void OpenTok.Session.SetEncryptionSecret | ( | string | secret | ) |
Sets the end-to-end encryption secret used by all publishers and subscribers.
See the End-to-end encryption developer guide.
secret | Value of the encryption secret. |
void OpenTok.Session.Subscribe | ( | Subscriber | subscriber | ) |
Start receiving and rendering audio-video stream data for the specified subscriber.
subscriber | The subscriber bound to the stream to be received. |
void OpenTok.Session.Unpublish | ( | Publisher | publisher | ) |
void OpenTok.Session.Unsubscribe | ( | Subscriber | subscriber | ) |
Stops subscribing (receiving a stream) to a specified subscriber in the session.
subscriber | The Subcriber you want to stop subscribing to. |
|
Whether the client can only subscribe to streams, or both publish and subscribe to streams, based on the role assigned to the token used to connect to the session.
|
Returns the Connection corresponding to this client's connection to this Session.
EventHandler<ArchiveStartedEventArgs> OpenTok.Session.ArchiveStarted |
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.
EventHandler<ArchiveStoppedEventArgs> OpenTok.Session.ArchiveStopped |
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.
EventHandler OpenTok.Session.Connected |
Sent when the client connects to the Vonage Video API session.
EventHandler<ConnectionEventArgs> OpenTok.Session.ConnectionCreated |
Sent when another client connects to the session.
The ConnectionEventArgs.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 sends the Connected event.
EventHandler<ConnectionEventArgs> OpenTok.Session.ConnectionDropped |
Sent when another client leaves the session.
The ConnectionEventArgs.Connection object represents the client's previous connection to the session. Note that this method is called when other clients leave the session. When your own client client disconnects, the Session object sends the Connected event.
EventHandler OpenTok.Session.Disconnected |
Sent when the client disconnects from the Vonage Video API session.
EventHandler<ErrorEventArgs> OpenTok.Session.Error |
Sent when something goes wrong when connecting or connected to the session.
This event is sent if the attempt to connect to the session fails. It is also sent if the connection to the session drops due to an error after a successful connection, and in this case the event is sent just before the Disconnected event is sent.
EventHandler<MuteForcedEventArgs> OpenTok.Session.MuteForced |
Called when a moderator forces clients publishing streams to the session to mute audio (the IsActive
property of the MuteForcedEventArgs object is set to true
), or when a moderator disables the mute audio state in the session (the IsActive
property of the MuteForcedEventArgs object is set to false
).
EventHandler OpenTok.Session.ReconnectionStart |
Sent when the local client has lost its connection to an Vonage Video API session and is trying to reconnect. This results from a loss in network connectivity.
If the client can reconnect to the session, the Session object sends the ReconnectionSuccess event. Otherwise, if the client cannot reconnect, the Session object sends the Disconnected event.
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.
EventHandler OpenTok.Session.ReconnectionSuccess |
Invoked when the local client has reconnected to the Vonage Video API session after its network connection was lost temporarily.
When the connection is lost, the Session object sends the Session.ReconnectionStart event, prior to sending the Session.ReconnectionSuccess event. If the client cannot reconnect to the session, the Session object sends the Session.Disconnected event.
Any existing publishers and subscribers are automatically reconnected when the client reconnects and this method is called.
By default, any signals initiated by the local client using the SendSignal(string, string, Connection, bool) method are sent when the client reconnects. To prevent any signals initiated while disconnected from being sent, set the retryAfterReconnect
parameter of the SendSignal method to false
. (All signals sent by other clients while your client was disconnected are received upon reconnecting.)
EventHandler<SignalEventArgs> OpenTok.Session.Signal |
Called when a signal is received in the session.
EventHandler<StreamEventArgs> OpenTok.Session.StreamDimensionsChanged |
Called when the video dimensions of a stream in the session change. The StreamEventArgs.Stream object represents a snapshot of stream at the time of the callback.
EventHandler<StreamEventArgs> OpenTok.Session.StreamDropped |
Sent when another client stops publishing a stream to this Vonage Video API session.
The StreamEventArgs.Stream object represents a snapshot of stream at the time of the callback. It can be used to identify a corresponding Subscriber (if there is one).
EventHandler<StreamEventArgs> OpenTok.Session.StreamHasAudioChanged |
Called when a stream in the session changes between having audio and not having audio. The StreamEventArgs.Stream object represents a snapshot of stream at the time of the callback.
EventHandler<StreamEventArgs> OpenTok.Session.StreamHasCaptionsChanged |
Called when a stream in the session changes between having captions and not having captions.
EventHandler<StreamEventArgs> OpenTok.Session.StreamHasVideoChanged |
Called when a stream in the session changes between having video and not having video. The StreamEventArgs.Stream object represents a snapshot of stream at the time of the callback.
EventHandler<StreamEventArgs> OpenTok.Session.StreamReceived |
Sent when a there is a new stream published by another client in this Vonage Video API session.
The StreamEventArgs.Stream object represents a snapshot of stream at the time of the callback. Create a Subscriber and call the Subscribe(Subscriber) method to subscribe to the stream.