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/ https://www.w3.org/TR/webrtc/
An instance of DataChannel is created either by manually calling
Namespace: Microsoft.MixedReality.WebRTC
Assembly: Microsoft.MixedReality.WebRTC.dll
Syntax
public class DataChannel : object
Properties
| Improve this Doc View SourceID
The unique identifier of the data channel in the current connection.
Declaration
public int ID { get; }
Property Value
Type | Description |
---|---|
Int32 |
Label
The data channel name in the current connection.
Declaration
public string Label { get; }
Property Value
Type | Description |
---|---|
String |
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
The PeerConnection object this data channel was created from and is attached to.
Declaration
public PeerConnection PeerConnection { get; }
Property Value
Type | Description |
---|---|
PeerConnection |
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. 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. |
Remarks
The code handling this event should unwind the stack before using any other MR-WebRTC APIs; re-entrancy is not supported.
See Also
Methods
| Improve this Doc View SourceSendMessage(IntPtr, UInt64)
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(IntPtr message, ulong size)
Parameters
Type | Name | Description |
---|---|---|
IntPtr | message | The message to send to the remote peer. |
UInt64 | size | The size of the message to send in octects. |
See Also
| Improve this Doc View SourceSendMessage(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. |
Exceptions
Type | Condition |
---|---|
DataChannelNotOpenException | The data channel is not open yet. |
See Also
Events
| Improve this Doc View SourceBufferingChanged
Event triggered when the data channel buffering changes. Users should 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 |
Remarks
The code handling this event should unwind the stack before using any other MR-WebRTC APIs; re-entrancy is not supported.
See Also
| Improve this Doc View SourceMessageReceived
Event triggered 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 SourceMessageReceivedUnsafe
Event fires when a message is received through the data channel.
Declaration
public event Action<IntPtr, ulong> MessageReceivedUnsafe
Event Type
Type | Description |
---|---|
Action<IntPtr, UInt64> |
See Also
| Improve this Doc View SourceStateChanged
Event triggered when the data channel state changes. The new state is available in State.
Declaration
public event Action StateChanged
Event Type
Type | Description |
---|---|
Action |
Remarks
The code handling this event should unwind the stack before using any other MR-WebRTC APIs; re-entrancy is not supported.