Interface PEPeer

    • Method Detail

      • addListener

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

        void removeListener​(PEPeerListener listener)
        Remove peer listener.
        Parameters:
        listener -
      • getPeerState

        int getPeerState()
      • getPeerSource

        java.lang.String getPeerSource()
      • isMyPeer

        boolean isMyPeer()
        Whether or not this is a 'dummy' peer that represents our presence in a swarm
        Returns:
      • getId

        byte[] getId()
      • getIp

        java.lang.String getIp()
      • getAlternativeIPv6

        java.net.InetAddress getAlternativeIPv6()
        Returns:
        an ipv6 address under which the peer should be connectable if it announced one, null otherwise
      • getPort

        int getPort()
        Get the peer's local TCP connection port.
        Returns:
        local port
      • getIPHostName

        java.lang.String getIPHostName()
        Gets the host name for the IP, if possible, IP as string otherwise
        Returns:
        hostname or IP
      • 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:
      • isPieceAvailable

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

        boolean transferAvailable()
      • setSnubbed

        void setSnubbed​(boolean b)
      • isChokingMe

        boolean isChokingMe()
        Is the peer choking me.
        Returns:
        true if I am choked by the peer, false if not
      • isUnchokeOverride

        boolean isUnchokeOverride()
      • isChokedByMe

        boolean isChokedByMe()
        Am I choking the peer.
        Returns:
        true if the peer is choked, false if not
      • sendChoke

        void sendChoke()
      • sendUnChoke

        void sendUnChoke()
      • isInteresting

        boolean isInteresting()
        Am I Interested in the peer.
        Returns:
        true if peer is interesting, false if not
      • isInterested

        boolean isInterested()
        Is the peer Interested in me.
        Returns:
        true if the peer is interested in me, false if not
      • isDownloadPossible

        boolean isDownloadPossible()
        checks several factors within the object so the caller wouldn't need to for convienience and speed.
        Returns:
        true if none of several criteria indicate a request can't be made of the peer
      • isSeed

        boolean isSeed()
      • isRelativeSeed

        boolean isRelativeSeed()
        Returns:
        true if the peer is only uploading and can't use the data we have to offer (we're seeding) or we can't use the data he has to offer (we're downloading)
      • isSnubbed

        boolean isSnubbed()
      • getSnubbedTime

        long getSnubbedTime()
      • isIncoming

        boolean isIncoming()
      • hasReceivedBitField

        boolean hasReceivedBitField()
      • getPercentDoneInThousandNotation

        int getPercentDoneInThousandNotation()
        Get the peer's torrent completion percentage in thousand-notation, i.e. 53.7% is returned as the value 0537.
        Returns:
        the percentage the peer has complete
      • getClient

        java.lang.String getClient()
      • isOptimisticUnchoke

        boolean isOptimisticUnchoke()
      • setOptimisticUnchoke

        void setOptimisticUnchoke​(boolean is_optimistic)
      • setUploadHint

        void setUploadHint​(int timeToSpread)
      • getUploadHint

        int getUploadHint()
      • setUniqueAnnounce

        void setUniqueAnnounce​(int uniquePieceNumber)
      • getUniqueAnnounce

        int getUniqueAnnounce()
      • getConsecutiveNoRequestCount

        int getConsecutiveNoRequestCount()
      • setConsecutiveNoRequestCount

        void setConsecutiveNoRequestCount​(int num)
      • setUploadRateLimitBytesPerSecond

        void setUploadRateLimitBytesPerSecond​(int bytes)
      • setDownloadRateLimitBytesPerSecond

        void setDownloadRateLimitBytesPerSecond​(int bytes)
      • getUploadRateLimitBytesPerSecond

        int getUploadRateLimitBytesPerSecond()
      • getDownloadRateLimitBytesPerSecond

        int getDownloadRateLimitBytesPerSecond()
      • addRateLimiter

        void addRateLimiter​(LimitedRateGroup limiter,
                            boolean upload)
      • removeRateLimiter

        void removeRateLimiter​(LimitedRateGroup limiter,
                               boolean upload)
      • setUploadDisabled

        void setUploadDisabled​(java.lang.Object key,
                               boolean disabled)
      • setDownloadDisabled

        void setDownloadDisabled​(java.lang.Object key,
                                 boolean disabled)
      • isUploadDisabled

        boolean isUploadDisabled()
      • isDownloadDisabled

        boolean isDownloadDisabled()
      • updateAutoUploadPriority

        void updateAutoUploadPriority​(java.lang.Object key,
                                      boolean inc)
      • getData

        java.lang.Object getData​(java.lang.String key)
        To retreive arbitrary objects against a peer.
      • setData

        void setData​(java.lang.String key,
                     java.lang.Object value)
        To store arbitrary objects against a peer.
      • getUserData

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

        void setUserData​(java.lang.Object key,
                         java.lang.Object value)
        To store arbitrary objects against a peer.
      • getPluginConnection

        Connection getPluginConnection()
        Get the 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
      • getMessagingMode

        int getMessagingMode()
      • getEncryption

        java.lang.String getEncryption()
        Returns name of encryption used by the peer
        Returns:
      • getProtocol

        java.lang.String getProtocol()
      • getProtocolQualifier

        java.lang.String getProtocolQualifier()
      • getSupportedMessages

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

        void addReservedPieceNumber​(int pieceNumber)
        adds the reserved piece for piece picking by this peer
      • removeReservedPieceNumber

        void removeReservedPieceNumber​(int pieceNumber)
      • getReservedPieceNumbers

        int[] getReservedPieceNumbers()
        Get the reserved pieces for piece picking by this peer
      • getIncomingRequestCount

        int getIncomingRequestCount()
      • getOutgoingRequestCount

        int getOutgoingRequestCount()
      • getIncomingRequestedPieceNumbers

        int[] getIncomingRequestedPieceNumbers()
        get a list of piece numbers the peer has requested
        Returns:
        list of Long() representing the piece number requested, in order
      • getOutgoingRequestedPieceNumbers

        int[] getOutgoingRequestedPieceNumbers()
        get a list of piece numbers the we have requested from peer
        Returns:
        list of Long() representing the piece number requested, oldest to newest
      • getPercentDoneOfCurrentIncomingRequest

        int getPercentDoneOfCurrentIncomingRequest()
      • getPercentDoneOfCurrentOutgoingRequest

        int getPercentDoneOfCurrentOutgoingRequest()
      • getBytesRemaining

        long getBytesRemaining()
      • setSuspendedLazyBitFieldEnabled

        void setSuspendedLazyBitFieldEnabled​(boolean enable)
        Enable suspended lazy bitfield for this peer - we will appear incomplete until this is disabled, at which point (well, fairly soon after) the bitfield will be completed
        Parameters:
        enable -
      • getTimeSinceConnectionEstablished

        long getTimeSinceConnectionEstablished()
        Get the time since this connection was first established. NOTE: This method will always return 0 at any time before the underlying transport is fully connected, i.e. before handshaking begins.
        Returns:
        time count in ms
      • setLastPiece

        void setLastPiece​(int i)
      • getLastPiece

        int getLastPiece()
      • isLANLocal

        boolean isLANLocal()
      • resetLANLocalStatus

        void resetLANLocalStatus()
      • sendRequestHint

        boolean sendRequestHint​(int piece_number,
                                int offset,
                                int length,
                                int life)
        Send a request hint to the peer.
        Parameters:
        piece_number -
        offset -
        length -
        life -
        Returns:
        true if sent, false otherwise
      • getRequestHint

        int[] getRequestHint()
        Get current request hint for a given piece for this peer.
        Returns:
        null if no hint int[]{ piece_number, offset, length } if hint found
      • clearRequestHint

        void clearRequestHint()
      • sendStatsRequest

        void sendStatsRequest​(java.util.Map request)
      • setHaveAggregationEnabled

        void setHaveAggregationEnabled​(boolean enabled)
      • getHandshakeReservedBytes

        byte[] getHandshakeReservedBytes()
      • getClientNameFromPeerID

        java.lang.String getClientNameFromPeerID()
      • getClientNameFromExtensionHandshake

        java.lang.String getClientNameFromExtensionHandshake()
      • isPriorityConnection

        boolean isPriorityConnection()
      • setPriorityConnection

        void setPriorityConnection​(boolean is_priority)
      • isClosed

        boolean isClosed()