Skip to main content
Version: 20 Mar 2024

NativeBindings

Native bindings for the MLWebRTC.DataChannel class.

Inherits from:
MagicLeapNativeBindings

Public Methods

MLResult.Code MLWebRTCDataChannelCreate

Creates a data channel.

public MLResult.Code MLWebRTCDataChannelCreate(
ulong connectionHandle,
string label,
out ulong dataChannelHandle
)

Parameters

TypeNameDescription
ulongconnectionHandleThe connection to associate the data channel with.
stringlabelThe label to give the data channel.
out ulongdataChannelHandleThe handle of the data channel after it is created.

Returns: MLResult.Result will be MLResult.Code.Ok if destroying all handles was successful. MLResult.Result will be MLResult.Code.MismatchingHandle if an incorrect handle was sent. MLResult.Result will be MLResult.Code.PermissionDenied if necessary permission is missing. MLResult.Result will be MLResult.Code.UnspecifiedFailure if failed due to other internal error.


MLResult.Code MLWebRTCDataChannelDestroy

Destroys a data channel.

public MLResult.Code MLWebRTCDataChannelDestroy(
ulong connectionHandle,
ulong dataChannelHandle
)

Parameters

TypeNameDescription
ulongconnectionHandleThe handle of the associated connection.
ulongdataChannelHandleThe handle of the data channel.

Returns: MLResult.Result will be MLResult.Code.Ok if destroying all handles was successful. MLResult.Result will be MLResult.Code.MismatchingHandle if an incorrect handle was sent. MLResult.Result will be MLResult.Code.PermissionDenied if necessary permission is missing. MLResult.Result will be MLResult.Code.UnspecifiedFailure if failed due to other internal error.


MLResult.Code MLWebRTCDataChannelGetLabel

Gets the label of a data channel, call MLWebRTCDataChannelReleaseLabelMemory after.

public MLResult.Code MLWebRTCDataChannelGetLabel(
ulong dataChannelHandle,
out IntPtr label
)

Parameters

TypeNameDescription
ulongdataChannelHandleThe handle of the data channel.
out IntPtrlabelPointer to the unmanaged label string.

Returns: MLResult.Result will be MLResult.Code.Ok if destroying all handles was successful. MLResult.Result will be MLResult.Code.MismatchingHandle if an incorrect handle was sent. MLResult.Result will be MLResult.Code.PermissionDenied if necessary permission is missing. MLResult.Result will be MLResult.Code.UnspecifiedFailure if failed due to other internal error.


MLResult.Code MLWebRTCDataChannelIsOpen

Gets if a data channel is open.

public MLResult.Code MLWebRTCDataChannelIsOpen(
ulong dataChannelHandle,
out bool isOpen
)

Parameters

TypeNameDescription
ulongdataChannelHandleThe handle of the data channel.
out boolisOpenTrue if the data channel is open.

Returns: MLResult.Result will be MLResult.Code.Ok if destroying all handles was successful. MLResult.Result will be MLResult.Code.MismatchingHandle if an incorrect handle was sent. MLResult.Result will be MLResult.Code.PermissionDenied if necessary permission is missing. MLResult.Result will be MLResult.Code.UnspecifiedFailure if failed due to other internal error.


MLResult.Code MLWebRTCDataChannelReleaseLabelMemory

Releases the memory created when calling MLWebRTCDataChannelGetLabel.

public MLResult.Code MLWebRTCDataChannelReleaseLabelMemory(
ulong dataChannelHandle,
IntPtr label
)

Parameters

TypeNameDescription
ulongdataChannelHandleThe handle of the data channel.
IntPtrlabelPointer to the unmanaged label string.

Returns: MLResult.Result will be MLResult.Code.Ok if destroying all handles was successful. MLResult.Result will be MLResult.Code.MismatchingHandle if an incorrect handle was sent. MLResult.Result will be MLResult.Code.PermissionDenied if necessary permission is missing. MLResult.Result will be MLResult.Code.UnspecifiedFailure if failed due to other internal error.


MLResult.Code MLWebRTCDataChannelSendMessage

Sends a message to a data channel.

public MLResult.Code MLWebRTCDataChannelSendMessage(
ulong dataChannelHandle,
in MLWebRTCDataChannelMessage message
)

Parameters

TypeNameDescription
ulongdataChannelHandleThe handle of the data channel.
in MLWebRTCDataChannelMessagemessageNative message object to send to the data channel.

Returns: MLResult.Result will be MLResult.Code.Ok if destroying all handles was successful. MLResult.Result will be MLResult.Code.MismatchingHandle if an incorrect handle was sent. MLResult.Result will be MLResult.Code.PermissionDenied if necessary permission is missing. MLResult.Result will be MLResult.Code.UnspecifiedFailure if failed due to other internal error.


MLResult.Code MLWebRTCDataChannelSetEventCallbacks

Sets the callbacks for a data channel.

public MLResult.Code MLWebRTCDataChannelSetEventCallbacks(
ulong dataChannelHandle,
in MLWebRTCDataChannelEventCallbacks callbacks
)

Parameters

TypeNameDescription
ulongdataChannelHandleThe handle of the data channel.
in MLWebRTCDataChannelEventCallbackscallbacksNative callbacks object to set the data channel with.

Returns: MLResult.Result will be MLResult.Code.Ok if destroying all handles was successful. MLResult.Result will be MLResult.Code.MismatchingHandle if an incorrect handle was sent. MLResult.Result will be MLResult.Code.PermissionDenied if necessary permission is missing. MLResult.Result will be MLResult.Code.UnspecifiedFailure if failed due to other internal error.


delegate void OnClosedDelegate

A delegate that describes the requirements of the OnClosed callback.

public delegate void OnClosedDelegate(
IntPtr context
)

Parameters

TypeNameDescription
IntPtrcontextPointer to a context object.

delegate void OnMessageDelegate

A delegate that describes the requirements of the OnMessage callback.

public delegate void OnMessageDelegate(
in MLWebRTCDataChannelMessage message,
IntPtr context
)

Parameters

TypeNameDescription
in MLWebRTCDataChannelMessagemessageThe native message object received.
IntPtrcontextPointer to a context object.

delegate void OnOpenedDelegate

A delegate that describes the requirements of the OnOpened callback.

public delegate void OnOpenedDelegate(
IntPtr context
)

Parameters

TypeNameDescription
IntPtrcontextPointer to a context object.

MLResult.Code SendMessageToDataChannel

Sends a string message to a data channel.

public static MLResult.Code SendMessageToDataChannel(
MLWebRTC.DataChannel dataChannel,
string message
)

Parameters

TypeNameDescription
MLWebRTC.DataChanneldataChannelData channel to send the message to.
stringmessageThe string to send.

Returns: MLResult.Result will be MLResult.Code.Ok if destroying all handles was successful. MLResult.Result will be MLResult.Code.MismatchingHandle if an incorrect handle was sent. MLResult.Result will be MLResult.Code.PermissionDenied if necessary permission is missing. MLResult.Result will be MLResult.Code.UnspecifiedFailure if failed due to other internal error.


MLResult.Code SendMessageToDataChannel< T >

Sends a string message to a data channel.

public static MLResult.Code SendMessageToDataChannel< T >(
MLWebRTC.DataChannel dataChannel,
T [] message
)

Parameters

TypeNameDescription
MLWebRTC.DataChanneldataChannelData channel to send the message to.
T []messageThe byte array to send.

Returns: MLResult.Result will be MLResult.Code.Ok if destroying all handles was successful. MLResult.Result will be MLResult.Code.MismatchingHandle if an incorrect handle was sent. MLResult.Result will be MLResult.Code.PermissionDenied if necessary permission is missing. MLResult.Result will be MLResult.Code.UnspecifiedFailure if failed due to other internal error.


MLResult.Code SetCallbacks

Sets the callbacks of a data channel.

public static MLResult.Code SetCallbacks(
MLWebRTC.DataChannel dataChannel
)

Parameters

TypeNameDescription
MLWebRTC.DataChanneldataChannelThe data channel to reference for the callbacks.

Returns: MLResult.Result will be MLResult.Code.Ok if destroying all handles was successful. MLResult.Result will be MLResult.Code.MismatchingHandle if an incorrect handle was sent. MLResult.Result will be MLResult.Code.PermissionDenied if necessary permission is missing. MLResult.Result will be MLResult.Code.UnspecifiedFailure if failed due to other internal error.