Interface Peer
- All Known Implementing Classes:
ExternalSeedPeer, PeerImpl
public interface Peer
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionvoidaddListener(PeerListener2 listener) Add peer listener.voidaddRateLimiter(RateLimiter limiter, boolean is_upload) booleanaddRequest(PeerReadRequest request) voidbindConnection(ConnectionStub stub) voidcancelRequest(PeerReadRequest request) voidboolean[]Get the network connection that backs this peer.int[]int[]byte[]byte[]getId()getIp()Get the peer's local TCP connection port.intintintint[]intintgetPort()int[]getRateLimiters(boolean is_upload) longintgetState()getStats()Message[]Get the list of messages that this peer and us mutually understand.intGet the TCP port this peer is listening for incoming connections on.intGet the UDP port this peer is listening for incoming connections on.intGet the UDP port this peer is listening on for non-data connectionsgetUserData(Object key) booleanisChoked()booleanbooleanThis is much list isTransferAvailable(), except is more comprehensive.booleanbooleanbooleanbooleanbooleanisMyPeer()booleanbooleanisPieceAvailable(int pieceNumber) booleanbooleanisSeed()booleanbooleanlongreadBytes(long max) Rate control - gives the maximum number of bytes that can be read from this connection at this time and returns the actual number readvoidremoveListener(PeerListener2 listener) Remove peer listener.voidremoveRateLimiter(RateLimiter limiter, boolean is_upload) voidbooleanrequestAllocationStarts(int[] base_priorities) voidvoidsetOptimisticUnchoke(boolean is_optimistic) voidsetPriorityConnection(boolean is_priority) voidsetSnubbed(boolean b) voidsetUserData(Object key, Object value) booleanWhether or not this peer supports the advanced messaging API.longwriteBytes(long max)
-
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
-
PR_PROTOCOL
-
PR_PROTOCOL_QUALIFIER
-
PR_FORCE_CONNECTION
-
PR_PREFER_UTP
-
PR_PEER_SOURCE
-
-
Method Details
-
bindConnection
-
getManager
PeerManager getManager() -
isMyPeer
boolean isMyPeer() -
getState
int getState() -
getId
byte[] getId() -
getIp
-
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
long readBytes(long 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
long writeBytes(long 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
-
requestAllocationStarts
boolean requestAllocationStarts(int[] base_priorities) -
getPriorityOffsets
int[] getPriorityOffsets() -
requestAllocationComplete
void requestAllocationComplete() -
addRequest
-
close
-
getCurrentIncomingRequestProgress
int[] getCurrentIncomingRequestProgress() -
getOutgoingRequestedPieceNumbers
int[] getOutgoingRequestedPieceNumbers() -
getOutgoingRequestCount
int getOutgoingRequestCount() -
getCurrentOutgoingRequestProgress
int[] getCurrentOutgoingRequestProgress() -
addListener
-
removeListener
-
getConnection
-
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
-
getUserData
-
getHandshakeReservedBytes
byte[] getHandshakeReservedBytes() -
isPriorityConnection
boolean isPriorityConnection() -
setPriorityConnection
void setPriorityConnection(boolean is_priority) -
addRateLimiter
- Parameters:
limiter- create via ConnectionManageris_upload- false -> download limit- Since:
- 4.7.0.3
-
removeRateLimiter
-
getRateLimiters
-
getDescriptor
PeerDescriptor getDescriptor()
-