class WebPeer extends Peer implements EepGet.StatusListener
| Modifier and Type | Field and Description |
|---|---|
static byte[] |
IDBytes |
_log, CHECK_PERIOD, magnetState, metainfo, RATE_DEPTH, state| Constructor and Description |
|---|
WebPeer(PeerCoordinator coord,
URI uri,
PeerID peerID,
MetaInfo metainfo)
Outgoing connection.
|
| Modifier and Type | Method and Description |
|---|---|
void |
attemptFailed(String url,
long bytesTransferred,
long bytesRemaining,
int currentAttempt,
int numRetries,
Exception cause) |
void |
attempting(String url) |
void |
bytesTransferred(long alreadyTransferred,
int currentWrite,
long bytesTransferred,
long bytesRemaining,
String url)
Total length should be == alreadyTransferred + currentWrite + bytesRemaining for all calls
|
(package private) void |
cancel(int piece)
Tell the other side that we are no longer interested in any of the outstanding requests (if
any) for this piece.
|
int |
completed()
Return how much the peer has
|
(package private) void |
disconnect() |
void |
downloaded(int size)
Increment the counter.
|
boolean |
equals(Object o)
Two Peers are equal when they have the same PeerID.
|
long |
getInactiveTime() |
long |
getMaxInactiveTime() |
int |
getMaxPipeline() |
String |
getSocket() |
int |
hashCode()
The hash code of a Peer is the hash code of the peerID.
|
void |
have(int piece)
Tell the peer we have another piece.
|
void |
headerReceived(String url,
int attemptNum,
String key,
String val)
Note: Headers are not processed, and this is not called, for most error response codes,
unless setWriteErrorToOutput() is called before fetch().
|
boolean |
isChoked()
Whether or not the peer choked us.
|
boolean |
isChoking()
Whether or not we are choking the peer.
|
boolean |
isCompleted()
Return if a peer is a seeder
|
boolean |
isConnected() |
boolean |
isInterested()
Whether or not the peer is interested in pieces we have.
|
boolean |
isInteresting()
Whether or not the peer has pieces we want from it.
|
boolean |
isWebPeer() |
void |
keepAlive()
Send keepalive
|
(package private) void |
request()
Update the request queue.
|
void |
retransmitRequests()
Retransmit outstanding requests if necessary
|
void |
runConnection(I2PSnarkUtil util,
PeerListener listener,
BandwidthListener bwl,
BitField ignore,
MagnetState mState,
boolean uploadOnly)
Runs the connection to the other peer.
|
void |
setChoking(boolean choke)
Sets whether or not we are choking the peer.
|
void |
setInteresting(boolean interest)
Deprecated.
|
boolean |
shouldRequest(int size)
Should we request this many bytes?
|
String |
toString()
Returns the String representation of the peerID.
|
void |
transferComplete(long alreadyTransferred,
long bytesTransferred,
long bytesRemaining,
String url,
String outputFile,
boolean notModified) |
void |
transferFailed(String url,
long bytesTransferred,
long bytesRemaining,
int currentAttempt) |
disconnect, getDestination, getDownBWLimit, getDownloaded, getDownloadRate, getHandshakeMap, getMagnetState, getPeerID, getPexLastSent, getTotalCommentsSent, getUpBWLimit, getUploaded, getUploadRate, getWhenConnected, isIncoming, overDownBWLimit, overUpBWLimit, sendExtension, setHandshakeMap, setMetaInfo, setPexLastSent, setRateHistory, setTotalCommentsSent, shouldRequest, shouldSend, supportsFast, uploadedclone, finalize, getClass, notify, notifyAll, wait, wait, waitcompareTopublic WebPeer(PeerCoordinator coord, URI uri, PeerID peerID, MetaInfo metainfo)
uri - must be http with .i2p hostmetainfo - non-nullpublic void attemptFailed(String url, long bytesTransferred, long bytesRemaining, int currentAttempt, int numRetries, Exception cause)
attemptFailed in interface EepGet.StatusListenerEepGet.StatusListener.bytesTransferred(long, int, long, long, java.lang.String)public void attempting(String url)
attempting in interface EepGet.StatusListenerpublic void bytesTransferred(long alreadyTransferred,
int currentWrite,
long bytesTransferred,
long bytesRemaining,
String url)
EepGet.StatusListenerbytesTransferred in interface EepGet.StatusListeneralreadyTransferred - total of all attempts, not including currentWrite
If nonzero on the first call, a partial file of that length was found,
_and_ the server supports resume.
If zero on a subsequent call after some bytes are transferred
(and presumably after an attemptFailed), the server does _not_
support resume and we had to start over.
To track _actual_ transfer if the output file could already exist,
the listener should keep its own counter,
or subtract the initial alreadyTransferred value.
And watch out for alreadyTransferred resetting if a resume failed...currentWrite - since last call to the listenerbytesTransferred - includes headers, retries, redirects, discarded partial downloads, ...bytesRemaining - on this attempt only, currentWrite already subtracted -
or -1 if chunked encoding or server does not return a lengthvoid cancel(int piece)
Peerpublic int completed()
Peervoid disconnect()
disconnect in class Peerpublic void downloaded(int size)
Peerdownloaded in interface BandwidthListenerdownloaded in class Peersize - the number of bytes receivedpublic boolean equals(Object o)
public long getInactiveTime()
getInactiveTime in class Peerpublic long getMaxInactiveTime()
getMaxInactiveTime in class Peerpublic int getMaxPipeline()
getMaxPipeline in class Peerpublic String getSocket()
public int hashCode()
public void have(int piece)
Peerpublic void headerReceived(String url, int attemptNum, String key, String val)
EepGet.StatusListenerheaderReceived in interface EepGet.StatusListenerpublic boolean isChoked()
Peerpublic boolean isChoking()
Peerpublic boolean isCompleted()
PeerisCompleted in class Peerpublic boolean isConnected()
isConnected in class Peerpublic boolean isInterested()
PeerisInterested in class Peerpublic boolean isInteresting()
PeerisInteresting in class Peerpublic void keepAlive()
Peervoid request()
Peerpublic void retransmitRequests()
PeerretransmitRequests in class Peerpublic void runConnection(I2PSnarkUtil util, PeerListener listener, BandwidthListener bwl, BitField ignore, MagnetState mState, boolean uploadOnly)
runConnection in class Peerignore - our bitfield, ignoreuploadOnly - if we are complete with skipped files, i.e. a partial seedpublic void setChoking(boolean choke)
PeersetChoking in class Peer@Deprecated public void setInteresting(boolean interest)
PeersetInteresting in class Peerpublic boolean shouldRequest(int size)
shouldRequest in class Peerpublic String toString()
Peerpublic void transferComplete(long alreadyTransferred,
long bytesTransferred,
long bytesRemaining,
String url,
String outputFile,
boolean notModified)
transferComplete in interface EepGet.StatusListeneroutputFile - null if unknown (output stream constructor)EepGet.StatusListener.bytesTransferred(long, int, long, long, java.lang.String)public void transferFailed(String url, long bytesTransferred, long bytesRemaining, int currentAttempt)
transferFailed in interface EepGet.StatusListenerEepGet.StatusListener.bytesTransferred(long, int, long, long, java.lang.String)