Skip to content

WebRTCDataChannel

Inherits: PacketPeer < RefCounted < Object

Inherited by: WebRTCDataChannelExtension

Type Name Default
WriteMode write_mode 1
Returns Method
void close()
int get_buffered_amount() const
int get_id() const
String get_label() const
int get_max_packet_life_time() const
int get_max_retransmits() const
String get_protocol() const
ChannelState get_ready_state() const
bool is_negotiated() const
bool is_ordered() const
Error poll()
bool was_string_packet() const

WriteMode

enum WriteMode

WRITE_MODE_TEXT = 0

Tells the channel to send data over this channel as text. An external peer (non-Orblit) would receive this as a string.

WRITE_MODE_BINARY = 1

Tells the channel to send data over this channel as binary. An external peer (non-Orblit) would receive this as array buffer or blob.

ChannelState

enum ChannelState

STATE_CONNECTING = 0

The channel was created, but it’s still trying to connect.

STATE_OPEN = 1

The channel is currently open, and data can flow over it.

STATE_CLOSING = 2

The channel is being closed, no new messages will be accepted, but those already in queue will be flushed.

STATE_CLOSED = 3

The channel was closed, or connection failed.

write_mode

WriteMode write_mode = 1

The transfer mode to use when sending outgoing packet. Either text or binary.

close

void close()

Closes this data channel, notifying the other peer.

get_buffered_amount

int get_buffered_amount() const

Returns the number of bytes currently queued to be sent over this channel.

get_id

int get_id() const

Returns the ID assigned to this channel during creation (or auto-assigned during negotiation).

If the channel is not negotiated out-of-band the ID will only be available after the connection is established (will return 65535 until then).

get_label

String get_label() const

Returns the label assigned to this channel during creation.

get_max_packet_life_time

int get_max_packet_life_time() const

Returns the maxPacketLifeTime value assigned to this channel during creation.

Will be 65535 if not specified.

get_max_retransmits

int get_max_retransmits() const

Returns the maxRetransmits value assigned to this channel during creation.

Will be 65535 if not specified.

get_protocol

String get_protocol() const

Returns the sub-protocol assigned to this channel during creation. An empty string if not specified.

get_ready_state

ChannelState get_ready_state() const

Returns the current state of this channel.

is_negotiated

bool is_negotiated() const

Returns true if this channel was created with out-of-band configuration.

is_ordered

bool is_ordered() const

Returns true if this channel was created with ordering enabled (default).

poll

Error poll()

Reserved, but not used for now.

was_string_packet

bool was_string_packet() const

Returns true if the last received packet was transferred as text. See write_mode.