API reference / @jsprismarine/native-network / DataChannel
Class: DataChannel
Defined in: packages/native-network/src/PeerConnection.ts:80
A data channel on a native peer connection.
Events: open, close, error (Error), message (Buffer, binary flag), bufferedamountlow.
Extends
EventEmitter
Constructors
Constructor
new DataChannel(
network,id,label,open):DataChannel
Defined in: packages/native-network/src/PeerConnection.ts:89
Parameters
network
The loaded library.
id
number
libdatachannel's id for the channel.
label
string
The channel's label.
open
boolean
Whether it is open already, as an incoming channel often is.
Returns
DataChannel
Overrides
EventEmitter.constructor
Properties
id
readonlyid:number
Defined in: packages/native-network/src/PeerConnection.ts:91
libdatachannel's id for the channel.
label
readonlylabel:string
Defined in: packages/native-network/src/PeerConnection.ts:92
The channel's label.
Accessors
bufferedAmount
Get Signature
get bufferedAmount():
number
Defined in: packages/native-network/src/PeerConnection.ts:106
Bytes queued in libdatachannel and not yet handed to SCTP.
Returns
number
readyState
Get Signature
get readyState():
"connecting"|"closed"|"open"|"closing"
Defined in: packages/native-network/src/PeerConnection.ts:101
connecting, open, closing or closed, as the W3C readyState.
Returns
"connecting" | "closed" | "open" | "closing"
Methods
close()
close():
void
Defined in: packages/native-network/src/PeerConnection.ts:129
Closes the channel; close follows, once the stream is reset.
Returns
void
send()
send(
data):boolean
Defined in: packages/native-network/src/PeerConnection.ts:123
Sends one message.
Parameters
data
Uint8Array
The message's bytes.
Returns
boolean
Whether libdatachannel took it; false on a channel that is not open.
setBufferedAmountLowThreshold()
setBufferedAmountLowThreshold(
amount):void
Defined in: packages/native-network/src/PeerConnection.ts:114
Fires bufferedamountlow once the buffered amount falls to this many bytes.
Parameters
amount
number
The threshold.
Returns
void