Module webrtc.java

Class RTCDataChannel


  • public class RTCDataChannel
    extends dev.onvoid.webrtc.internal.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 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 initially null, 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 using send(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.DisposableNativeObject
        Invoke native object destructors and free native resources.
        Specified by:
        dispose in class dev.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.