DataChannel
Class that represents a data channel used by the MLWebRTC API.
Public Fields
Label
Gets the label of the data channel.
public string Label { get; set; }
ParentConnection
Gets the connection associated with the data channel.
public PeerConnection ParentConnection { get; set; }
Type | Description |
---|---|
PeerConnection | Class that represents a connection used by the MLWebRTC API. |
Public Methods
DataChannel CreateLocal
Creates an initialized DataChannel object.
public static DataChannel CreateLocal(
MLWebRTC.PeerConnection connection,
out MLResult result,
string label ="local"
)
Parameters
Type | Name | Description |
---|---|---|
MLWebRTC.PeerConnection | connection | The connection to create the data channel with. |
out MLResult | label | The label to give the data channel. |
string | result | The MLResult object of the inner platform call(s). |
Returns: An initialized DataChannel object.
MLResult Destroy
Destroys the data channel object.
public MLResult Destroy()
Returns: MLResult.Result will be MLResult.Code.Ok if destroying all handles was successful. MLResult.Result will be MLResult.Code.WebRTCResultInstanceNotCreated if MLWebRTC instance was not created. MLResult.Result will be MLResult.Code.WebRTCResultMismatchingHandle if an incorrect handle was sent.
MLResult IsOpen
Checks if the data channel is currently open.
public MLResult IsOpen(
out bool open
)
Parameters
Type | Name | Description |
---|---|---|
out bool | open | True if data channel is open. |
Returns: MLResult.Result will be MLResult.Code.Ok if destroying all handles was successful. MLResult.Result will be MLResult.Code.WebRTCResultInstanceNotCreated if MLWebRTC instance was not created. MLResult.Result will be MLResult.Code.WebRTCResultMismatchingHandle if an incorrect handle was sent. MLResult.Result will be MLResult.Code.InvalidParam if an invalid parameter was passed.
delegate void OnClosedDelegate
Delegate that describes the requirements of the OnClosed callback.
public delegate void OnClosedDelegate(
MLWebRTC.DataChannel dataChannel
)
Parameters
Type | Name | Description |
---|---|---|
MLWebRTC.DataChannel | dataChannel | The data channel associated with the event. |
delegate void OnMessageBinaryDelegate
Delegate that describes the requirements of the OnMessageBinary callback.
public delegate void OnMessageBinaryDelegate(
MLWebRTC.DataChannel dataChannel,
byte [] message
)
Parameters
Type | Name | Description |
---|---|---|
MLWebRTC.DataChannel | dataChannel | The data channel associated with the event. |
byte [] | message | The message byte array. |
delegate void OnMessageTextDelegate
Delegate that describes the requirements of the OnMessageText callback.
public delegate void OnMessageTextDelegate(
MLWebRTC.DataChannel dataChannel,
string message
)
Parameters
Type | Name | Description |
---|---|---|
MLWebRTC.DataChannel | dataChannel | The data channel associated with the event. |
string | message | The message string. |
delegate void OnOpenedDelegate
Delegate that describes the requirements of the OnOpened callback.
public delegate void OnOpenedDelegate(
MLWebRTC.DataChannel dataChannel
)
Parameters
Type | Name | Description |
---|---|---|
MLWebRTC.DataChannel | dataChannel | The data channel associated with the event. |
MLResult SendMessage
Sends a string message to a data channel.
public MLResult SendMessage(
string message
)
Parameters
Type | Name | Description |
---|---|---|
string | message | The string to send. |
Returns: MLResult.Result will be MLResult.Code.Ok if destroying all handles was successful. MLResult.Result will be MLResult.Code.WebRTCResultInstanceNotCreated if MLWebRTC instance was not created. MLResult.Result will be MLResult.Code.WebRTCResultMismatchingHandle if an incorrect handle was sent. MLResult.Result will be MLResult.Code.InvalidParam if an invalid parameter was passed. MLResult.Result will be MLResult.Code.WebRTCResultDataChannelIsClosed if data channel is closed.
MLResult SendMessage< T >
Sends a byte array message to a data channel.
public MLResult SendMessage< T >(
T [] message
)
Parameters
Type | Name | Description |
---|---|---|
T [] | message | The byte array to send. |
Returns: MLResult.Result will be MLResult.Code.Ok if destroying all handles was successful. MLResult.Result will be MLResult.Code.WebRTCResultInstanceNotCreated if MLWebRTC instance was not created. MLResult.Result will be MLResult.Code.WebRTCResultMismatchingHandle if an incorrect handle was sent. MLResult.Result will be MLResult.Code.InvalidParam if an invalid parameter was passed. MLResult.Result will be MLResult.Code.WebRTCResultDataChannelIsClosed if data channel is closed.
Public Events
OnClosed
Event invoked for when a data channel closes.
public OnClosedDelegate OnClosed()
OnMessageBinary
Event invoked for when a data channel receives a binary message.
public OnMessageBinaryDelegate OnMessageBinary()
OnMessageText
Event invoked for when a data channel receives a text message.
public OnMessageTextDelegate OnMessageText()
OnOpened
Event invoked for when a data channel opens.
public OnOpenedDelegate OnOpened()