Table of Contents

Class WebRtcWsTwoWaySession

Namespace
VAST.WebRTC
Assembly
VAST.WebRTC.dll

Represents a two-way WebRTC session over WebSocket signalling, implementing IWebRtcSignalling for peer-to-peer communication with both local media publishing and remote media playback capabilities.

public class WebRtcWsTwoWaySession : IWebRtcSignalling, IDisposable
Inheritance
WebRtcWsTwoWaySession
Implements
Inherited Members

Constructors

WebRtcWsTwoWaySession(string, string)

Initializes a new instance of the WebRtcWsTwoWaySession class with the specified signalling server URI and room identifier.

public WebRtcWsTwoWaySession(string signallingServerUri, string room)

Parameters

signallingServerUri string

The WebSocket URI of the signalling server.

room string

The room identifier to join.

Fields

MaxPeerCount

The maximum number of peers allowed in a single session.

public const int MaxPeerCount = 10

Field Value

int

Properties

AllowEchoCanceller

Gets or sets a value indicating whether the echo canceller is allowed. This value can only be changed before the session is started.

public bool AllowEchoCanceller { get; set; }

Property Value

bool

CurrentState

Gets the current session state.

public WebRtcWsTwoWaySession.State CurrentState { get; }

Property Value

WebRtcWsTwoWaySession.State

EchoCanceller

Gets or sets the echo canceller instance used for audio processing. This value can only be changed before the session is started.

public IEchoCanceller EchoCanceller { get; set; }

Property Value

IEchoCanceller

IceServers

Gets or sets the ICE server configuration string used for establishing WebRTC connections.

public string IceServers { get; set; }

Property Value

string

Methods

AddRemotePeer(IMediaPlayer)

Adds a media player for a remote peer. Must be called before the session is started.

public void AddRemotePeer(IMediaPlayer player)

Parameters

player IMediaPlayer

The media player to use for rendering remote peer media.

Dispose()

Releases all resources used by the WebRtcWsTwoWaySession class.

public void Dispose()

SendToPeer(object, long, string)

Sends a signalling message to the specified peer via the WebSocket connection.

public void SendToPeer(object caller, long peerId, string data)

Parameters

caller object

The calling object that initiated the send.

peerId long

The identifier of the target peer.

data string

The message data to send.

SetLocalPeer(IMediaSource, IMediaSource)

Sets the local peer media sources for video and audio capture. Must be called before the session is started.

public void SetLocalPeer(IMediaSource videoSource, IMediaSource audioSource)

Parameters

videoSource IMediaSource

The video capture source, or null if no video is provided.

audioSource IMediaSource

The audio capture source, or null if no audio is provided.

Start()

Starts the two-way WebRTC session by connecting to the signalling server and initializing local media capture.

public void Start()

Stop()

Stops the two-way WebRTC session, disconnecting all peers and releasing resources.

public void Stop()

Events

Error

Occurs when an error is encountered during session operations.

public event EventHandler<ErrorEventArgs> Error

Event Type

EventHandler<ErrorEventArgs>