WebRtcPeerConnection
A WebRTC interface requiring a target-platform implementation.
Controls SDP/ICE and data channels through a selected implementation. A checked clean Windows C# project without an external backend selects empty WebRTCPeerConnectionExtension. An SDK class or even Error.Ok from an empty virtual method does not prove a working connection.
Verify implementation, diagnostics, signaling, channel creation/opening and cleanup on the target platform. CreateOffer does not create a signaling service; exchange SDP/ICE separately between the correct participants. Connected WebRTC is not verified in this Windows fixture.
Declarations checked against C# SDK 1.0.0. Expand a name to see declarations and documentation.
Constructors1
WebRtcPeerConnectionConstructor
public WebRtcPeerConnection();Methods12
AddIceCandidateError
public Error AddIceCandidate(string media, int index, string name);Passes a remote ICE candidate to the implementation. Associate it with the correct signaling session and remote-description readiness.
| Name | Type | Default |
|---|---|---|
media | string | — |
index | int | — |
name | string | — |
ErrorClosevoid
public void Close();Close the peer connection and all data channels associated with it.
Note: You cannot reuse this object for a new connection unless you call WebRtcPeerConnection.Initialize.
CreateDataChannelWebRtcDataChannel
public WebRtcDataChannel CreateDataChannel(string label, Reckfell.Collections.Dictionary options = null);Creates a channel through the implementation. On the initiator create required channels before the offer; an object is not necessarily an open channel.
| Name | Type | Default |
|---|---|---|
label | string | — |
options | Reckfell.Collections.Dictionary | null |
WebRtcDataChannelCreateOfferError
public Error CreateOffer();Requests SDP offer creation; SessionDescriptionCreated supplies the result. The application supplies signaling and delivery to the other participant.
ErrorGetConnectionStateWebRtcPeerConnection.ConnectionState
public WebRtcPeerConnection.ConnectionState GetConnectionState();Returns the connection state.
WebRtcPeerConnection.ConnectionStateGetGatheringStateWebRtcPeerConnection.GatheringState
public WebRtcPeerConnection.GatheringState GetGatheringState();Returns the ICE WebRtcPeerConnection.GatheringState of the connection. This lets you detect, for example, when collection of ICE candidates has finished.
WebRtcPeerConnection.GatheringStateGetSignalingStateWebRtcPeerConnection.SignalingState
public WebRtcPeerConnection.SignalingState GetSignalingState();Returns the signaling state on the local end of the connection while connecting or reconnecting to another peer.
WebRtcPeerConnection.SignalingStateInitializeError
public Error Initialize(Reckfell.Collections.Dictionary configuration = null);Passes configuration to the selected implementation. A zero result on empty Extension does not prove implementation: inspect required-virtual diagnostics and actual exchange.
| Name | Type | Default |
|---|---|---|
configuration | Reckfell.Collections.Dictionary | null |
ErrorPollError
public Error Poll();Call this method frequently (e.g. in Entity._Process or Entity._PhysicsProcess) to properly receive signals.
ErrorSetDefaultExtensionvoid
public static void SetDefaultExtension(StringName extensionClass);Selects a registered implementation inheriting the required Extension class. Does not download a library or verify compatibility/operation.
| Name | Type | Default |
|---|---|---|
extensionClass | StringName | — |
SetLocalDescriptionError
public Error SetLocalDescription(string type, string sdp);Sets the SDP description of the local peer. This should be called in response to WebRtcPeerConnection.SessionDescriptionCreated.
After calling this function the peer will start emitting WebRtcPeerConnection.IceCandidateCreated (unless an Error different from OK is returned).
| Name | Type | Default |
|---|---|---|
type | string | — |
sdp | string | — |
ErrorSetRemoteDescriptionError
public Error SetRemoteDescription(string type, string sdp);Sets the SDP description of the remote peer. This should be called with the values generated by a remote peer and received over the signaling server.
If type is "offer" the peer will emit WebRtcPeerConnection.SessionDescriptionCreated with the appropriate answer.
If type is "answer" the peer will start emitting WebRtcPeerConnection.IceCandidateCreated.
| Name | Type | Default |
|---|---|---|
type | string | — |
sdp | string | — |
ErrorSignals and events3
DataChannelReceivedEvent
public event WebRtcPeerConnection.DataChannelReceivedEventHandler DataChannelReceived;Emitted when a new in-band channel is received, i.e. when the channel was created with negotiated: false (default).
The object will be an instance of WebRtcDataChannel. You must keep a reference of it or it will be closed automatically. See WebRtcPeerConnection.CreateDataChannel.
| Name | Type | Default |
|---|---|---|
channel | WebRtcDataChannel | — |
IceCandidateCreatedEvent
public event WebRtcPeerConnection.IceCandidateCreatedEventHandler IceCandidateCreated;Emitted when a new ICE candidate has been created. The three parameters are meant to be passed to the remote peer over the signaling server.
| Name | Type | Default |
|---|---|---|
media | string | — |
index | long | — |
name | string | — |
SessionDescriptionCreatedEvent
public event WebRtcPeerConnection.SessionDescriptionCreatedEventHandler SessionDescriptionCreated;Emitted after a successful call to WebRtcPeerConnection.CreateOffer or WebRtcPeerConnection.SetRemoteDescription (when it generates an answer). The parameters are meant to be passed to WebRtcPeerConnection.SetLocalDescription on this object, and sent to the remote peer over the signaling server.
| Name | Type | Default |
|---|---|---|
type | string | — |
sdp | string | — |
WebRtcPeerConnection.ConnectionState
| Value | Description |
|---|---|
Closed = 5 | The peer connection is closed (after calling |
Connected = 2 | The peer is connected, all ICE transports are connected. |
Connecting = 1 | The peer is connecting, ICE is in progress, none of the transports has failed. |
Disconnected = 3 | At least one ICE transport is disconnected. |
Failed = 4 | One or more of the ICE transports failed. |
New = 0 | The connection is new, data channels and an offer can be created in this state. |
WebRtcPeerConnection.GatheringState
| Value | Description |
|---|---|
Complete = 2 | The ICE agent has finished gathering candidates. If something happens that requires collecting new candidates, such as a new interface being added or the addition of a new ICE server, the state will revert to gathering to gather those candidates. |
Gathering = 1 | The ICE agent is in the process of gathering candidates for the connection. |
New = 0 | The peer connection was just created and hasn't done any networking yet. |
WebRtcPeerConnection.SignalingState
| Value | Description |
|---|---|
Closed = 5 | The |
HaveLocalOffer = 1 | The local peer has called |
HaveLocalPranswer = 3 | The offer sent by the remote peer has been applied and an answer has been created and applied by calling |
HaveRemoteOffer = 2 | The remote peer has created an offer and used the signaling server to deliver it to the local peer, which has set the offer as the remote description by calling |
HaveRemotePranswer = 4 | A provisional answer has been received and successfully applied in response to an offer previously sent and established by calling |
Stable = 0 | There is no ongoing exchange of offer and answer underway. This may mean that the |