Package dev.onvoid.webrtc
Class RTCDataChannel
java.lang.Object
dev.onvoid.webrtc.internal.NativeObject
dev.onvoid.webrtc.internal.DisposableNativeObject
dev.onvoid.webrtc.RTCDataChannel
public class RTCDataChannel extends DisposableNativeObject
Represents a bi-directional data channel between two peers. An RTCDataChannel
is created via a factory method on an
RTCPeerConnection
.- Author:
- Alex Andres
-
Method Summary
Modifier and Type Method Description void
close()
Closes this RTCDataChannel.void
dispose()
Invoke native object destructors and free native resources.long
getBufferedAmount()
Returns the number of bytes of application data (UTF-8 text and binary data) that have been queued usingsend(RTCDataChannelBuffer)
.int
getId()
Returns the ID for this RTCDataChannel.java.lang.String
getLabel()
Returns the label that can be used to distinguish this RTCDataChannel object from other RTCDataChannel objects.int
getMaxPacketLifeTime()
Returns the length of the time window (in milliseconds) during which transmissions and retransmissions may occur in unreliable mode.int
getMaxRetransmits()
Returns the maximum number of retransmissions that are attempted in unreliable mode.java.lang.String
getProtocol()
Returns the name of the sub-protocol used with this RTCDataChannel.RTCDataChannelState
getState()
Returns the state of this RTCDataChannel object.boolean
isNegotiated()
Returns true if this RTCDataChannel was negotiated by the application, or false otherwise.boolean
isOrdered()
Returns true if the RTCDataChannel is ordered, and false if out of order delivery is allowed.boolean
isReliable()
Indicates whether the data channel is configured to use reliable transmission.void
registerObserver(RTCDataChannelObserver observer)
Register an observer to receive events from this RTCDataChannel.void
send(RTCDataChannelBuffer buffer)
Sends data in the provided buffer to the remote peer.void
unregisterObserver()
Unregister the last set RTCDataChannelObserver.
-
Method Details
-
registerObserver
Register an observer to receive events from this RTCDataChannel. The observer will replace the previously registered observer.- Parameters:
observer
- The new data channel observer.
-
unregisterObserver
public void unregisterObserver()Unregister the last set RTCDataChannelObserver. -
getLabel
public java.lang.String getLabel()Returns the label that can be used to distinguish this RTCDataChannel object from other RTCDataChannel objects.- Returns:
- The data channel label.
-
isReliable
public boolean isReliable()Indicates whether the data channel is configured to use reliable transmission.- Returns:
- true if the transmission is reliable, false otherwise.
-
isOrdered
public boolean isOrdered()Returns true if the RTCDataChannel is ordered, and false if out of order delivery is allowed.- Returns:
- true if message delivery is ordered, false otherwise.
-
getMaxPacketLifeTime
public int getMaxPacketLifeTime()Returns the length of the time window (in milliseconds) during which transmissions and retransmissions may occur in unreliable mode.- Returns:
- The maximum life-time of packets in unreliable mode.
-
getMaxRetransmits
public int getMaxRetransmits()Returns the maximum number of retransmissions that are attempted in unreliable mode.- Returns:
- The maximum number of retransmissions.
-
getProtocol
public java.lang.String getProtocol()Returns the name of the sub-protocol used with this RTCDataChannel.- Returns:
- The name of the sub-protocol used.
-
isNegotiated
public boolean isNegotiated()Returns true if this RTCDataChannel was negotiated by the application, or false otherwise.- Returns:
- true if the channel was negotiated by the application, false otherwise.
-
getId
public int getId()Returns the ID for this RTCDataChannel. The value is initiallynull
, which is what will be returned if the ID was not provided at channel creation time, and the DTLS role of the SCTP transport has not yet been negotiated. Otherwise, it will return the ID that was selected by the application. After the ID is set to a non-null value, it will not change.- Returns:
- the ID for this data channel.
-
getState
Returns the state of this RTCDataChannel object.- Returns:
- The current state of the data channel.
-
getBufferedAmount
public long getBufferedAmount()Returns the number of bytes of application data (UTF-8 text and binary data) that have been queued usingsend(RTCDataChannelBuffer)
. The value does not include framing overhead incurred by the protocol, or buffering done by the operating system or network hardware.- Returns:
- The number of bytes queued for transmission.
-
close
public void close()Closes this RTCDataChannel. It may be called regardless of whether the RTCDataChannel was created by this peer or the remote peer. -
dispose
public void dispose()Description copied from class:DisposableNativeObject
Invoke native object destructors and free native resources.- Specified by:
dispose
in classDisposableNativeObject
-
send
Sends data in the provided buffer to the remote peer.- Parameters:
buffer
- The buffer to be queued for transmission.- Throws:
java.lang.Exception
- If queuing data is not possible because not enough buffer space is available.
-