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.
Namespace: Microsoft.MixedReality.WebRTC
Assembly: Microsoft.MixedReality.WebRTC.dll
Syntax
public class DataChannel : IDisposable
Properties
| Improve this Doc View SourceID
Declaration
public int ID { get; }
Property Value
Type | Description |
---|---|
Int32 | The unique identifier of the data channel in the current connection. |
Label
Declaration
public string Label { get; }
Property Value
Type | Description |
---|---|
String | The data channel name in the current connection. |
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 |
|
See Also
| Improve this Doc View SourcePeerConnection
Declaration
public PeerConnection PeerConnection { get; }
Property Value
Type | Description |
---|---|
PeerConnection | The PeerConnection object this data channel was created from. |
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 |
|
See Also
| Improve this Doc View SourceState
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
Methods
| Improve this Doc View SourceDispose()
Remove the data track from the peer connection and destroy it.
Declaration
public void Dispose()
Finalize()
Finalizer to ensure the data track is removed from the peer connection and the managed resources are cleaned-up.
Declaration
protected void Finalize()
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
Events
| Improve this Doc View SourceBufferingChanged
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
| Improve this Doc View SourceMessageReceived
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
| Improve this Doc View SourceStateChanged
Event fired when the data channel state changes, as reported by State.
Declaration
public event Action StateChanged
Event Type
Type | Description |
---|---|
Action |