- java.lang.Object
-
- dev.onvoid.webrtc.internal.NativeObject
-
- dev.onvoid.webrtc.internal.DisposableNativeObject
-
- dev.onvoid.webrtc.RTCDataChannel
-
public class RTCDataChannel extends dev.onvoid.webrtc.internal.DisposableNativeObjectRepresents a bi-directional data channel between two peers. An RTCDataChannel is created via a factory method on anRTCPeerConnection.- Author:
- Alex Andres
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Closes this RTCDataChannel.voiddispose()Invoke native object destructors and free native resources.longgetBufferedAmount()Returns the number of bytes of application data (UTF-8 text and binary data) that have been queued usingsend(RTCDataChannelBuffer).intgetId()Returns the ID for this RTCDataChannel.StringgetLabel()Returns the label that can be used to distinguish this RTCDataChannel object from other RTCDataChannel objects.intgetMaxPacketLifeTime()Returns the length of the time window (in milliseconds) during which transmissions and retransmissions may occur in unreliable mode.intgetMaxRetransmits()Returns the maximum number of retransmissions that are attempted in unreliable mode.StringgetProtocol()Returns the name of the sub-protocol used with this RTCDataChannel.RTCDataChannelStategetState()Returns the state of this RTCDataChannel object.booleanisNegotiated()Returns true if this RTCDataChannel was negotiated by the application, or false otherwise.booleanisOrdered()Returns true if the RTCDataChannel is ordered, and false if out of order delivery is allowed.booleanisReliable()Indicates whether the data channel is configured to use reliable transmission.voidregisterObserver(RTCDataChannelObserver observer)Register an observer to receive events from this RTCDataChannel.voidsend(RTCDataChannelBuffer buffer)Sends data in the provided buffer to the remote peer.voidunregisterObserver()Unregister the last set RTCDataChannelObserver.
-
-
-
Method Detail
-
registerObserver
public void registerObserver(RTCDataChannelObserver observer)
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 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 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
public RTCDataChannelState 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:dev.onvoid.webrtc.internal.DisposableNativeObjectInvoke native object destructors and free native resources.- Specified by:
disposein classdev.onvoid.webrtc.internal.DisposableNativeObject
-
send
public void send(RTCDataChannelBuffer buffer) throws Exception
Sends data in the provided buffer to the remote peer.- Parameters:
buffer- The buffer to be queued for transmission.- Throws:
Exception- If queuing data is not possible because not enough buffer space is available.
-
-