Class WebRtcWsTwoWaySession
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
signallingServerUristringThe WebSocket URI of the signalling server.
roomstringThe room identifier to join.
Fields
MaxPeerCount
The maximum number of peers allowed in a single session.
public const int MaxPeerCount = 10
Field Value
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
CurrentState
Gets the current session state.
public WebRtcWsTwoWaySession.State CurrentState { get; }
Property Value
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
IceServers
Gets or sets the ICE server configuration string used for establishing WebRTC connections.
public string IceServers { get; set; }
Property Value
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
playerIMediaPlayerThe 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
callerobjectThe calling object that initiated the send.
peerIdlongThe identifier of the target peer.
datastringThe 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
videoSourceIMediaSourceThe video capture source, or
nullif no video is provided.audioSourceIMediaSourceThe audio capture source, or
nullif 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