Interface PEPeer

All Superinterfaces:
Taggable, Taggable
All Known Subinterfaces:
PEPeerTransport
All Known Implementing Classes:
PeerForeignDelegate, PEPeerControlImpl.MyPeer, PEPeerTransportProtocol

public interface PEPeer extends Taggable
  • Field Details

  • Method Details

    • addListener

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

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

      int getPeerState()
    • getManager

      PEPeerManager getManager()
    • getPeerSource

      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

      String getIp()
    • getAlternativeIPv6

      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

      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:
    • getAvailable

      BitFlags getAvailable()
    • 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 convenience 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()
    • getStats

      PEPeerStats getStats()
    • 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

      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)
    • getRateLimiters

      LimitedRateGroup[] getRateLimiters(boolean upload)
    • removeRateLimiter

      void removeRateLimiter(LimitedRateGroup limiter, boolean upload)
    • setUploadDisabled

      void setUploadDisabled(Object key, boolean disabled)
    • setDownloadDisabled

      void setDownloadDisabled(Object key, boolean disabled)
    • isUploadDisabled

      boolean isUploadDisabled()
    • isDownloadDisabled

      boolean isDownloadDisabled()
    • updateAutoUploadPriority

      void updateAutoUploadPriority(Object key, boolean inc)
    • getData

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

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

      Object getUserData(Object key)
    • setUserData

      void setUserData(Object key, Object value)
      To store arbitrary objects against a peer.
    • getNetworkConnection

      NetworkConnectionBase getNetworkConnection()
    • 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

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

      String getProtocol()
    • getProtocolQualifier

      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
    • getRecentPiecesSent

      default DiskManagerReadRequest[] getRecentPiecesSent()
    • getPercentDoneOfCurrentIncomingRequest

      default int getPercentDoneOfCurrentIncomingRequest()
    • getCurrentIncomingRequestProgress

      int[] getCurrentIncomingRequestProgress()
      Returns:
      null or { size, done }
    • getPercentDoneOfCurrentOutgoingRequest

      default int getPercentDoneOfCurrentOutgoingRequest()
    • getCurrentOutgoingRequestProgress

      int[] getCurrentOutgoingRequestProgress()
    • 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 -
    • getConnectionEstablishedMonoTime

      long getConnectionEstablishedMonoTime()
      Get the time this connection was first established. NOTE: This method will always return -1 at any time before the underlying transport is fully connected, i.e. before handshaking begins.
      Returns:
      mono time 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(Map request)
    • sendRejectRequest

      void sendRejectRequest(DiskManagerReadRequest request)
    • setHaveAggregationEnabled

      void setHaveAggregationEnabled(boolean enabled)
    • getHandshakeReservedBytes

      byte[] getHandshakeReservedBytes()
    • getClientNameFromPeerID

      String getClientNameFromPeerID()
    • getClientNameFromExtensionHandshake

      String getClientNameFromExtensionHandshake()
    • isPriorityConnection

      boolean isPriorityConnection()
    • setPriorityConnection

      void setPriorityConnection(boolean is_priority)
    • isClosed

      boolean isClosed()