reckfellENGINE

WebRtcPeerConnection

A WebRTC interface requiring a target-platform implementation.

On this page
class WebRtcPeerConnectionReckfellSharpInherits RefCounted

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.

Practical guide.

Declarations checked against C# SDK 1.0.0. Expand a name to see declarations and documentation.

Constructors1

WebRtcPeerConnectionConstructor
# WebRtcPeerConnection
C#
public WebRtcPeerConnection();

Methods12

AddIceCandidateError
# AddIceCandidate
C#
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.

Parameters
NameTypeDefault
mediastring—
indexint—
namestring—
Returns Error
Closevoid
# Close
C#
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
# CreateDataChannel
C#
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.

Parameters
NameTypeDefault
labelstring—
optionsReckfell.Collections.Dictionarynull
Returns WebRtcDataChannel
CreateOfferError
# CreateOffer
C#
public Error CreateOffer();

Requests SDP offer creation; SessionDescriptionCreated supplies the result. The application supplies signaling and delivery to the other participant.

Returns Error
GetConnectionStateWebRtcPeerConnection.ConnectionState
# GetConnectionState
C#
public WebRtcPeerConnection.ConnectionState GetConnectionState();

Returns the connection state.

Returns WebRtcPeerConnection.ConnectionState
GetGatheringStateWebRtcPeerConnection.GatheringState
# GetGatheringState
C#
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.

Returns WebRtcPeerConnection.GatheringState
GetSignalingStateWebRtcPeerConnection.SignalingState
# GetSignalingState
C#
public WebRtcPeerConnection.SignalingState GetSignalingState();

Returns the signaling state on the local end of the connection while connecting or reconnecting to another peer.

Returns WebRtcPeerConnection.SignalingState
InitializeError
# Initialize
C#
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.

Parameters
NameTypeDefault
configurationReckfell.Collections.Dictionarynull
Returns Error
PollError
# Poll
C#
public Error Poll();

Call this method frequently (e.g. in Entity._Process or Entity._PhysicsProcess) to properly receive signals.

Returns Error
SetDefaultExtensionvoid
# SetDefaultExtension
C#
public static void SetDefaultExtension(StringName extensionClass);

Selects a registered implementation inheriting the required Extension class. Does not download a library or verify compatibility/operation.

Parameters
NameTypeDefault
extensionClassStringName—
SetLocalDescriptionError
# SetLocalDescription
C#
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).

Parameters
NameTypeDefault
typestring—
sdpstring—
Returns Error
SetRemoteDescriptionError
# SetRemoteDescription
C#
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.

Parameters
NameTypeDefault
typestring—
sdpstring—
Returns Error

Signals and events3

DataChannelReceivedEvent
# DataChannelReceived
C#
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.

Handler parameters
NameTypeDefault
channelWebRtcDataChannel—
IceCandidateCreatedEvent
# IceCandidateCreated
C#
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.

Handler parameters
NameTypeDefault
mediastring—
indexlong—
namestring—
SessionDescriptionCreatedEvent
# SessionDescriptionCreated
C#
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.

Handler parameters
NameTypeDefault
typestring—
sdpstring—

WebRtcPeerConnection.ConnectionState

ValueDescription
Closed = 5

The peer connection is closed (after calling WebRtcPeerConnection.Close for example).

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

ValueDescription
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

ValueDescription
Closed = 5

The WebRtcPeerConnection has been closed.

HaveLocalOffer = 1

The local peer has called WebRtcPeerConnection.SetLocalDescription, passing in SDP representing an offer (usually created by calling WebRtcPeerConnection.CreateOffer), and the offer has been applied successfully.

HaveLocalPranswer = 3

The offer sent by the remote peer has been applied and an answer has been created and applied by calling WebRtcPeerConnection.SetLocalDescription. This provisional answer describes the supported media formats and so forth, but may not have a complete set of ICE candidates included. Further candidates will be delivered separately later.

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 WebRtcPeerConnection.SetRemoteDescription.

HaveRemotePranswer = 4

A provisional answer has been received and successfully applied in response to an offer previously sent and established by calling WebRtcPeerConnection.SetLocalDescription.

Stable = 0

There is no ongoing exchange of offer and answer underway. This may mean that the WebRtcPeerConnection is new (WebRtcPeerConnection.ConnectionState.New) or that negotiation is complete and a connection has been established (WebRtcPeerConnection.ConnectionState.Connected).

Reckfell Engine documentationBack to top ↑
QUICK LINKSGetting startedEntity hierarchyC# & .NET 10Scenes and prefabs
Reckfell guides and full API K
reckfellENGINE
RECKFELL ACCOUNT

Sign in

Sign in to your Reckfell account.

One account for the entire Reckfell platform.