Package com.biglybt.core.peer
Interface PEPeer
- All Known Subinterfaces:
PEPeerTransport
- All Known Implementing Classes:
PeerForeignDelegate
,PEPeerControlImpl.MyPeer
,PEPeerTransportProtocol
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final String[]
static final int
Fields inherited from interface com.biglybt.core.tag.Taggable
TT_DOWNLOAD, TT_NONE, TT_PEER
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addListener
(PEPeerListener listener) Add peer listener.void
addRateLimiter
(LimitedRateGroup limiter, boolean upload) void
addReservedPieceNumber
(int pieceNumber) adds the reserved piece for piece picking by this peervoid
long
long
Get the time this connection was first established.int
int[]
int[]
To retreive arbitrary objects against a peer.int
Returns name of encryption used by the peerbyte[]
byte[]
getId()
int
int[]
get a list of piece numbers the peer has requestedgetIp()
Gets the host name for the IP, if possible, IP as string otherwiseint
int
int
int[]
get a list of piece numbers the we have requested from peerint
int
Get the peer's torrent completion percentage in thousand-notation, i.e.default int
default int
Get the connection that backs this peer.int
getPort()
Get the peer's local TCP connection port.getRateLimiters
(boolean upload) default DiskManagerReadRequest[]
int[]
Get current request hint for a given piece for this peer.int[]
Get the reserved pieces for piece picking by this peerlong
getStats()
Message[]
Get the list of messages that this peer and us both 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 connectionsint
int
int
getUserData
(Object key) boolean
boolean
Am I choking the peer.boolean
Is the peer choking me.boolean
isClosed()
boolean
boolean
checks several factors within the object so the caller wouldn't need to for convenience and speed.boolean
boolean
Is the peer Interested in me.boolean
Am I Interested in the peer.boolean
boolean
isMyPeer()
Whether or not this is a 'dummy' peer that represents our presence in a swarmboolean
boolean
isPieceAvailable
(int pieceNumber) boolean
boolean
boolean
isSeed()
boolean
boolean
boolean
void
removeListener
(PEPeerListener listener) Remove peer listener.void
removeRateLimiter
(LimitedRateGroup limiter, boolean upload) void
removeReservedPieceNumber
(int pieceNumber) void
void
void
sendRejectRequest
(DiskManagerReadRequest request) boolean
sendRequestHint
(int piece_number, int offset, int length, int life) Send a request hint to the peer.void
sendStatsRequest
(Map request) void
void
setConsecutiveNoRequestCount
(int num) void
To store arbitrary objects against a peer.void
setDownloadDisabled
(Object key, boolean disabled) void
setDownloadRateLimitBytesPerSecond
(int bytes) void
setHaveAggregationEnabled
(boolean enabled) void
setLastPiece
(int i) void
setOptimisticUnchoke
(boolean is_optimistic) void
setPriorityConnection
(boolean is_priority) void
setSnubbed
(boolean b) 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 completedvoid
setUniqueAnnounce
(int uniquePieceNumber) void
setUploadDisabled
(Object key, boolean disabled) void
setUploadHint
(int timeToSpread) void
setUploadRateLimitBytesPerSecond
(int bytes) void
setUserData
(Object key, Object value) To store arbitrary objects against a peer.boolean
Whether or not this peer supports the advanced messaging API.boolean
void
updateAutoUploadPriority
(Object key, boolean inc) Methods inherited from interface com.biglybt.core.tag.Taggable
getTaggableID, getTaggableName, getTaggableResolver, getTaggableTransientProperty, getTaggableType, setTaggableTransientProperty
-
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:
-
StateNames
-
MESSAGING_BT_ONLY
static final int MESSAGING_BT_ONLY- See Also:
-
MESSAGING_AZMP
static final int MESSAGING_AZMP- See Also:
-
MESSAGING_LTEP
static final int MESSAGING_LTEP- See Also:
-
MESSAGING_EXTERN
static final int MESSAGING_EXTERN- See Also:
-
-
Method Details
-
addListener
Add peer listener.- Parameters:
listener
-
-
removeListener
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
-
getRateLimiters
-
removeRateLimiter
-
setUploadDisabled
-
setDownloadDisabled
-
isUploadDisabled
boolean isUploadDisabled() -
isDownloadDisabled
boolean isDownloadDisabled() -
updateAutoUploadPriority
-
getData
To retreive arbitrary objects against a peer. -
setData
To store arbitrary objects against a peer. -
getUserData
-
setUserData
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
-
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
-
sendRejectRequest
-
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()
-