Class Signaler
Abstract base class to simplify implementing a WebRTC signaling solution in Unity.
There is no requirement to use this class as a base class for a custom implementation, but it handles automatically registering the necessary PeerConnection event handlers, as well as dispatching free-threaded callbacks to the main Unity app thread for simplicity and safety, and leaves the implementation with instead with two sending methods SendMessageAsync(SdpMessage) and SendMessageAsync(IceCandidate) to implement, as well as handling received messages.
Namespace: Microsoft.MixedReality.WebRTC.Unity
Assembly: cs.temp.dll.dll
Syntax
public abstract class Signaler : MonoBehaviour
Fields
_mainThreadWorkQueue
Task queue used to defer actions to the main Unity app thread, which is the only thread with access to Unity objects.
Declaration
protected ConcurrentQueue<Action> _mainThreadWorkQueue
Field Value
Type | Description |
---|---|
ConcurrentQueue<Action> |
_nativePeer
Native PeerConnection object from the underlying WebRTC C# library, available once the peer has been initialized.
Declaration
protected PeerConnection _nativePeer
Field Value
Type | Description |
---|---|
PeerConnection |
PeerConnection
The PeerConnection this signaler needs to work for.
Declaration
public PeerConnection PeerConnection
Field Value
Type | Description |
---|---|
PeerConnection |
Methods
OnDisable()
Declaration
protected virtual void OnDisable()
OnEnable()
Declaration
protected virtual void OnEnable()
OnIceCandidateReadyToSend(IceCandidate)
Callback invoked when an ICE candidate message has been generated and is ready to be sent to the remote peer by the signaling object.
Declaration
protected virtual void OnIceCandidateReadyToSend(IceCandidate candidate)
Parameters
Type | Name | Description |
---|---|---|
IceCandidate | candidate | ICE candidate to send to the remote peer. |
OnPeerInitialized()
Callback fired from the PeerConnection when it finished initializing, to subscribe to signaling-related events.
Declaration
public void OnPeerInitialized()
OnPeerUninitializing()
Callback fired from the PeerConnection before it starts uninitializing itself and disposing of the underlying implementation object.
Declaration
public void OnPeerUninitializing()
OnSdpAnswerReadyToSend(SdpMessage)
Callback invoked when a local SDP answer has been generated and is ready to be sent to the remote peer by the signaling object.
Declaration
protected virtual void OnSdpAnswerReadyToSend(SdpMessage answer)
Parameters
Type | Name | Description |
---|---|---|
SdpMessage | answer | The SDP answer message to send. |
OnSdpOfferReadyToSend(SdpMessage)
Callback invoked when a local SDP offer has been generated and is ready to be sent to the remote peer by the signaling object.
Declaration
protected virtual void OnSdpOfferReadyToSend(SdpMessage offer)
Parameters
Type | Name | Description |
---|---|---|
SdpMessage | offer | The SDP offer message to send. |
SendMessageAsync(IceCandidate)
Asynchronously send an ICE candidate to the remote peer.
Declaration
public abstract Task SendMessageAsync(IceCandidate candidate)
Parameters
Type | Name | Description |
---|---|---|
IceCandidate | candidate | The ICE candidate to send to the remote peer. |
Returns
Type | Description |
---|---|
Task | A |
SendMessageAsync(SdpMessage)
Asynchronously send an SDP message to the remote peer.
Declaration
public abstract Task SendMessageAsync(SdpMessage message)
Parameters
Type | Name | Description |
---|---|---|
SdpMessage | message | The SDP message to send to the remote peer. |
Returns
Type | Description |
---|---|
Task | A |
Update()
Unity Engine Update() hook
Declaration
protected virtual void Update()