Class reference
WebRTCDataChannel
Inherits PacketPeer
Properties
int write_mode = 1
int write_mode = 1The transfer mode to use when sending outgoing packet. Either text or binary.
Methods
void close()
Closes this data channel, notifying the other peer.
int get_buffered_amount() const
int get_buffered_amount() constReturns the number of bytes currently queued to be sent over this channel.
int get_id() const
int get_id() constReturns 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).
String get_label() const
String get_label() constReturns the label assigned to this channel during creation.
int get_max_packet_life_time() const
int get_max_packet_life_time() constReturns the maxPacketLifeTime value assigned to this channel during creation. Will be 65535 if not specified.
int get_max_retransmits() const
int get_max_retransmits() constReturns the maxRetransmits value assigned to this channel during creation. Will be 65535 if not specified.
String get_protocol() const
String get_protocol() constReturns the sub-protocol assigned to this channel during creation. An empty string if not specified.
int get_ready_state() const
int get_ready_state() constReturns the current state of this channel.
bool is_negotiated() const
bool is_negotiated() constReturns true if this channel was created with out-of-band configuration.
bool is_ordered() const
bool is_ordered() constReturns true if this channel was created with ordering enabled (default).
int poll()
int poll()Reserved, but not used for now.
bool was_string_packet() const
bool was_string_packet() constReturns true if the last received packet was transferred as text. See write_mode.
Constants
WRITE_MODE_TEXT = 0
Tells the channel to send data over this channel as text. An external peer (non-Godot) 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-Godot) would receive this as array buffer or blob.
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.