Interface Peer

    • Field Detail

      • PR_PRIORITY_CONNECTION

        static final java.lang.Object PR_PRIORITY_CONNECTION
      • PR_PROTOCOL

        static final java.lang.Object PR_PROTOCOL
      • PR_PROTOCOL_QUALIFIER

        static final java.lang.Object PR_PROTOCOL_QUALIFIER
      • PR_FORCE_CONNECTION

        static final java.lang.Object PR_FORCE_CONNECTION
    • Method Detail

      • isMyPeer

        boolean isMyPeer()
      • getState

        int getState()
      • getId

        byte[] getId()
      • getIp

        java.lang.String getIp()
        Get the peer's local TCP connection port.
        Returns:
        local port
      • getTCPListenPort

        int getTCPListenPort()
        Get the TCP port this peer is listening for incoming connections on.
        Returns:
        TCP port, or 0 if port is unknown
      • getUDPListenPort

        int getUDPListenPort()
        Get the UDP port this peer is listening for incoming connections on.
        Returns:
        UDP port, or 0 if port is unknown
      • getUDPNonDataListenPort

        int getUDPNonDataListenPort()
        Get the UDP port this peer is listening on for non-data connections
        Returns:
      • getPort

        int getPort()
      • isLANLocal

        boolean isLANLocal()
      • resetLANLocalStatus

        void resetLANLocalStatus()
      • getAvailable

        boolean[] getAvailable()
      • isPieceAvailable

        boolean isPieceAvailable​(int pieceNumber)
        Parameters:
        pieceNumber - int
        Returns:
        true if this peers makes this piece available
      • isTransferAvailable

        boolean isTransferAvailable()
      • readBytes

        int readBytes​(int max)
        Rate control - gives the maximum number of bytes that can be read from this connection at this time and returns the actual number read
        Parameters:
        max -
        Returns:
      • writeBytes

        int writeBytes​(int max)
      • isDownloadPossible

        boolean isDownloadPossible()
        This is much list isTransferAvailable(), except is more comprehensive. That is; it checks a few more factors, within the object for speed, so that a more timely status is considered and the caller doesn't need to try to check each thing on it's own.
        Returns:
        true if several factors say downloading can be tried.
      • isChoked

        boolean isChoked()
      • isChoking

        boolean isChoking()
      • isInterested

        boolean isInterested()
      • isInteresting

        boolean isInteresting()
      • isSeed

        boolean isSeed()
      • isSnubbed

        boolean isSnubbed()
      • getSnubbedTime

        long getSnubbedTime()
      • setSnubbed

        void setSnubbed​(boolean b)
      • isIncoming

        boolean isIncoming()
      • getPercentDoneInThousandNotation

        int getPercentDoneInThousandNotation()
      • getClient

        java.lang.String getClient()
      • isOptimisticUnchoke

        boolean isOptimisticUnchoke()
      • setOptimisticUnchoke

        void setOptimisticUnchoke​(boolean is_optimistic)
      • getExpiredRequests

        java.util.List getExpiredRequests()
      • getRequests

        java.util.List getRequests()
      • getMaximumNumberOfRequests

        int getMaximumNumberOfRequests()
      • getNumberOfRequests

        int getNumberOfRequests()
      • requestAllocationStarts

        boolean requestAllocationStarts​(int[] base_priorities)
      • getPriorityOffsets

        int[] getPriorityOffsets()
      • requestAllocationComplete

        void requestAllocationComplete()
      • close

        void close​(java.lang.String reason,
                   boolean closedOnError,
                   boolean attemptReconnect)
      • getPercentDoneOfCurrentIncomingRequest

        int getPercentDoneOfCurrentIncomingRequest()
      • getOutgoingRequestedPieceNumbers

        int[] getOutgoingRequestedPieceNumbers()
      • getOutgoingRequestCount

        int getOutgoingRequestCount()
      • getPercentDoneOfCurrentOutgoingRequest

        int getPercentDoneOfCurrentOutgoingRequest()
      • addListener

        void addListener​(PeerListener2 listener)
        Add peer listener.
        Parameters:
        listener -
      • removeListener

        void removeListener​(PeerListener2 listener)
        Remove peer listener.
        Parameters:
        listener -
      • getConnection

        Connection getConnection()
        Get the network connection that backs this peer.
        Returns:
        connection
      • supportsMessaging

        boolean supportsMessaging()
        Whether or not this peer supports the advanced messaging API.
        Returns:
        true if extended messaging is supported, false if not
      • getSupportedMessages

        Message[] getSupportedMessages()
        Get the list of messages that this peer and us mutually understand.
        Returns:
        messages available for use, or null of supported is yet unknown
      • setUserData

        void setUserData​(java.lang.Object key,
                         java.lang.Object value)
      • getUserData

        java.lang.Object getUserData​(java.lang.Object key)
      • getHandshakeReservedBytes

        byte[] getHandshakeReservedBytes()
      • isPriorityConnection

        boolean isPriorityConnection()
      • setPriorityConnection

        void setPriorityConnection​(boolean is_priority)
      • addRateLimiter

        void addRateLimiter​(RateLimiter limiter,
                            boolean is_upload)
        Parameters:
        limiter - create via ConnectionManager
        is_upload - false -> download limit
        Since:
        4.7.0.3
      • removeRateLimiter

        void removeRateLimiter​(RateLimiter limiter,
                               boolean is_upload)
      • getRateLimiters

        RateLimiter[] getRateLimiters​(boolean is_upload)