Show / Hide Table of Contents

    Class DataChannel

    Encapsulates a data channel of a peer connection.

    A data channel is a pipe allowing to send and receive arbitrary data to the remote peer. Data channels are based on DTLS-SRTP, and are therefore secure (encrypted). Exact security guarantees are provided by the underlying WebRTC core implementation and the WebRTC standard itself.

    https://tools.ietf.org/wg/rtcweb/

    An instance of DataChannel is created by calling AddDataChannelAsync(String, Boolean, Boolean) or one of its variants. DataChannel cannot be instantiated directly.

    Inheritance
    Object
    DataChannel
    Namespace: Microsoft.MixedReality.WebRTC
    Assembly: Microsoft.MixedReality.WebRTC.dll
    Syntax
    public class DataChannel : IDisposable

    Properties

    | Improve this Doc View Source

    ID

    Declaration
    public int ID { get; }
    Property Value
    Type Description
    Int32

    The unique identifier of the data channel in the current connection.

    | Improve this Doc View Source

    Label

    Declaration
    public string Label { get; }
    Property Value
    Type Description
    String

    The data channel name in the current connection.

    | Improve this Doc View Source

    Ordered

    Indicates whether the data channel messages are ordered or not. Ordered messages are delivered in the order they are sent, at the cost of delaying later messages delivery to the application (via MessageReceived) when internally arriving out of order.

    Declaration
    public bool Ordered { get; }
    Property Value
    Type Description
    Boolean

    true if messages are ordered.

    See Also
    Reliable
    | Improve this Doc View Source

    PeerConnection

    Declaration
    public PeerConnection PeerConnection { get; }
    Property Value
    Type Description
    PeerConnection

    The PeerConnection object this data channel was created from.

    | Improve this Doc View Source

    Reliable

    Indicates whether the data channel messages are reliably delivered. Reliable messages are guaranteed to be delivered as long as the connection is not dropped. Unreliable messages may be silently dropped for whatever reason, and the implementation will not try to detect this nor resend them.

    Declaration
    public bool Reliable { get; }
    Property Value
    Type Description
    Boolean

    true if messages are reliable.

    See Also
    Ordered
    | Improve this Doc View Source

    State

    The channel connection state represents the connection status when creating or closing the data channel. Changes to this state are notified via the StateChanged event.

    Declaration
    public DataChannel.ChannelState State { get; }
    Property Value
    Type Description
    DataChannel.ChannelState

    The channel connection state.

    See Also
    StateChanged

    Methods

    | Improve this Doc View Source

    Dispose()

    Remove the data track from the peer connection and destroy it.

    Declaration
    public void Dispose()
    | Improve this Doc View Source

    Finalize()

    Finalizer to ensure the data track is removed from the peer connection and the managed resources are cleaned-up.

    Declaration
    protected void Finalize()
    | Improve this Doc View Source

    SendMessage(Byte[])

    Send a message through the data channel. If the message cannot be sent, for example because of congestion control, it is buffered internally. If this buffer gets full, an exception is thrown and this call is aborted. The internal buffering is monitored via the BufferingChanged event.

    Declaration
    public void SendMessage(byte[] message)
    Parameters
    Type Name Description
    Byte[] message

    The message to send to the remote peer.

    See Also
    InitializeAsync(PeerConnectionConfiguration, CancellationToken)
    Initialized
    BufferingChanged

    Events

    | Improve this Doc View Source

    BufferingChanged

    Event fired when the data channel buffering changes. Monitor this to ensure calls to SendMessage(Byte[]) do not fail. Internally the data channel contains a buffer of messages to send that could not be sent immediately, for example due to congestion control. Once this buffer is full, any further call to SendMessage(Byte[]) will fail until some mesages are processed and removed to make space.

    Declaration
    public event DataChannel.BufferingChangedDelegate BufferingChanged
    Event Type
    Type Description
    DataChannel.BufferingChangedDelegate
    See Also
    SendMessage(Byte[])
    | Improve this Doc View Source

    MessageReceived

    Event fires when a message is received through the data channel.

    Declaration
    public event Action<byte[]> MessageReceived
    Event Type
    Type Description
    Action<Byte[]>
    See Also
    SendMessage(Byte[])
    | Improve this Doc View Source

    StateChanged

    Event fired when the data channel state changes, as reported by State.

    Declaration
    public event Action StateChanged
    Event Type
    Type Description
    Action
    See Also
    State
    • Improve this Doc
    • View Source
    Back to top Generated by DocFX