API Docs for:
Show:

rtc.DataChannel Class

Module: rtc

A wrapper for RTCDataChannel. Used to transfer custom data between peers.

Constructor

rtc.DataChannel

(
  • channel
  • [max_buffer]
)

Parameters:

  • channel RTCDataChannel

    The wrapped native data channel

  • [max_buffer] Number optional

    The size of the send buffer after which we will delay sending

Item Index

Events

Methods

_actualSend

() private

Method which actually sends the data. Implements buffering

connect

() Promise

Connect to the DataChannel. You will receive messages and will be able to send after calling this.

Returns:

Promise:

Promise which resolves as soon as the DataChannel is open

label

() String

The label of the DataChannel used to distinguish multiple channels

Returns:

String:

The label

send

(
  • data
)
Promise

Send data to the peer through the DataChannel

Parameters:

  • data Object

    The data to be transferred

Returns:

Promise:

Promise which will be resolved when the data was passed to the native data channel

Events

closed

()

The channel was closed

message

(
  • data
)

A new messages was received. Triggers only after connect() was called

Parameters:

  • data ArrayBuffer

    The data received