WebRtcDataChannel

Abstract class representing a network channel which can be used for bidirectional peer-to-peer transfers of arbitrary data. Every data channel is associated with an WebRtcPeerConnection.

See also

Inheritors

Constructors

Link copied to clipboard
constructor(receiveOptions: DataChannelReceiveOptions)

Properties

Link copied to clipboard
abstract val bufferedAmount: Long

A number of bytes of data currently queued to be sent over the data channel.

Link copied to clipboard

A number of queued outgoing data bytes below which the buffer is considered to be "low." When the number of buffered outgoing bytes, as indicated by the bufferedAmount property, falls to or below this value, a DataChannelEvent.BufferedAmountLow event is fired. The default value is 0.

Link copied to clipboard
abstract val id: Int?

An ID number (between 0 and 65,534) which uniquely identifies the data channel. It can be null when the data channel is created but not yet assigned an ID.

Link copied to clipboard
abstract val label: String

A string containing a name describing the data channel.

Link copied to clipboard
abstract val maxPacketLifeTime: Int?

The maximum number of milliseconds that attempts to transfer a message may take in unreliable mode.

Link copied to clipboard
abstract val maxRetransmits: Int?

The maximum number of times the user agent should attempt to retransmit a message which fails the first time in unreliable mode.

Link copied to clipboard
abstract val negotiated: Boolean

Indicates whether the data channel was negotiated by the application or the WebRTC layer.

Link copied to clipboard
abstract val ordered: Boolean

Indicates whether messages sent on the data channel are required to arrive at their destination in the same order in which they were sent, or if they're allowed to arrive out-of-order.

Link copied to clipboard
abstract val protocol: String

The name of the sub-protocol being used on the data channel, if any; otherwise, the empty string.

Link copied to clipboard

A state of the data channel's underlying data connection.

Functions

Link copied to clipboard
open override fun close()

Closes the data channel and releases all associated resources. Automatically invokes closeTransport. Accessing the channel after this operation could throw an exception.

Link copied to clipboard
abstract fun closeTransport()

Closes the data channel transport. The underlying message receiving channel will be closed.

Link copied to clipboard
fun WebRtcDataChannel.getNative(): DataChannel

Returns implementation of the data channel that is used under the hood. Use it with caution.

fun WebRtcDataChannel.getNative(): RTCDataChannel

Returns implementation of the data channel that is used under the hood. Use it with caution.

Link copied to clipboard
open suspend override fun receive(): WebRtc.DataChannel.Message

Suspends until a message is available in the data channel and returns it.

Link copied to clipboard
open suspend override fun receiveBinary(): ByteArray

Receives a binary message from the data channel.

Link copied to clipboard
open suspend override fun receiveText(): String

Receives a text message from the data channel.

Link copied to clipboard
abstract suspend fun send(bytes: ByteArray)

Sends binary data through the data channel.

abstract suspend fun send(text: String)

Sends a text message through the data channel.

Link copied to clipboard
abstract fun setBufferedAmountLowThreshold(threshold: Long)

Sets the threshold for the buffered amount of data below which the buffer is considered to be "low." When the buffered amount falls to or below this value, a DataChannelEvent.BufferedAmountLow event is fired.

Link copied to clipboard

Immediately returns a message from the data channel or null if no message is available.

Link copied to clipboard
open override fun tryReceiveBinary(): ByteArray?

Immediately returns binary data from the data channel or null if no binary message is available.

Link copied to clipboard
open override fun tryReceiveText(): String?

Immediately returns text data from the data channel or null if no text message is available.