Interface Peer

All Known Implementing Classes:
ExternalSeedPeer, PeerImpl

public interface Peer
  • Field Details

    • CONNECTING

      static final int CONNECTING
      See Also:
    • HANDSHAKING

      static final int HANDSHAKING
      See Also:
    • TRANSFERING

      static final int TRANSFERING
      See Also:
    • CLOSING

      static final int CLOSING
      See Also:
    • DISCONNECTED

      static final int DISCONNECTED
      See Also:
    • PR_PRIORITY_CONNECTION

      static final Object PR_PRIORITY_CONNECTION
    • PR_PROTOCOL

      static final Object PR_PROTOCOL
    • PR_PROTOCOL_QUALIFIER

      static final Object PR_PROTOCOL_QUALIFIER
    • PR_FORCE_CONNECTION

      static final Object PR_FORCE_CONNECTION
    • PR_PREFER_UTP

      static final Object PR_PREFER_UTP
    • PR_PEER_SOURCE

      static final Object PR_PEER_SOURCE
  • Method Details

    • bindConnection

      void bindConnection(ConnectionStub stub)
    • getManager

      PeerManager getManager()
    • isMyPeer

      boolean isMyPeer()
    • getState

      int getState()
    • getId

      byte[] getId()
    • getIp

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

      PeerStats getStats()
    • isIncoming

      boolean isIncoming()
    • getPercentDoneInThousandNotation

      int getPercentDoneInThousandNotation()
    • getClient

      String getClient()
    • isOptimisticUnchoke

      boolean isOptimisticUnchoke()
    • setOptimisticUnchoke

      void setOptimisticUnchoke(boolean is_optimistic)
    • getExpiredRequests

      List<PeerReadRequest> getExpiredRequests()
    • getRequests

      List<PeerReadRequest> getRequests()
    • getMaximumNumberOfRequests

      int getMaximumNumberOfRequests()
    • getNumberOfRequests

      int getNumberOfRequests()
    • cancelRequest

      void cancelRequest(PeerReadRequest request)
    • requestAllocationStarts

      boolean requestAllocationStarts(int[] base_priorities)
    • getPriorityOffsets

      int[] getPriorityOffsets()
    • requestAllocationComplete

      void requestAllocationComplete()
    • addRequest

      boolean addRequest(PeerReadRequest request)
    • close

      void close(String reason, int reason_code, boolean closedOnError, boolean attemptReconnect)
    • getCurrentIncomingRequestProgress

      int[] getCurrentIncomingRequestProgress()
    • getOutgoingRequestedPieceNumbers

      int[] getOutgoingRequestedPieceNumbers()
    • getOutgoingRequestCount

      int getOutgoingRequestCount()
    • getCurrentOutgoingRequestProgress

      int[] getCurrentOutgoingRequestProgress()
    • 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(Object key, Object value)
    • getUserData

      Object getUserData(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)
    • getDescriptor

      PeerDescriptor getDescriptor()