Package com.biglybt.pif.peers
Interface Peer
- All Known Implementing Classes:
ExternalSeedPeer
,PeerImpl
public interface Peer
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionvoid
addListener
(PeerListener2 listener) Add peer listener.void
addRateLimiter
(RateLimiter limiter, boolean is_upload) boolean
addRequest
(PeerReadRequest request) void
bindConnection
(ConnectionStub stub) void
cancelRequest
(PeerReadRequest request) void
boolean[]
Get the network connection that backs this peer.int[]
int[]
byte[]
byte[]
getId()
getIp()
Get the peer's local TCP connection port.int
int
int
int[]
int
int
getPort()
int[]
getRateLimiters
(boolean is_upload) long
int
getState()
getStats()
Message[]
Get the list of messages that this peer and us mutually understand.int
Get the TCP port this peer is listening for incoming connections on.int
Get the UDP port this peer is listening for incoming connections on.int
Get the UDP port this peer is listening on for non-data connectionsgetUserData
(Object key) boolean
isChoked()
boolean
boolean
This is much list isTransferAvailable(), except is more comprehensive.boolean
boolean
boolean
boolean
boolean
isMyPeer()
boolean
boolean
isPieceAvailable
(int pieceNumber) boolean
boolean
isSeed()
boolean
boolean
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 readvoid
removeListener
(PeerListener2 listener) Remove peer listener.void
removeRateLimiter
(RateLimiter limiter, boolean is_upload) void
boolean
requestAllocationStarts
(int[] base_priorities) void
void
setOptimisticUnchoke
(boolean is_optimistic) void
setPriorityConnection
(boolean is_priority) void
setSnubbed
(boolean b) void
setUserData
(Object key, Object value) boolean
Whether or not this peer supports the advanced messaging API.int
writeBytes
(int 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
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
-
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
Add peer listener.- Parameters:
listener
-
-
removeListener
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
-
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()
-