|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.lang.Thread
jBittorrentAPI.PeerUpdater
public class PeerUpdater
Class providing methods to enable communication between the client and a tracker. Provide method to decode and parse tracker response.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class java.lang.Thread |
---|
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler |
Field Summary | |
---|---|
private long |
downloaded
|
private boolean |
end
|
private java.lang.String |
event
|
private boolean |
first
|
private byte[] |
id
|
private int |
interval
|
private long |
left
|
private javax.swing.event.EventListenerList |
listeners
|
private int |
listeningPort
|
private int |
minInterval
|
private java.util.LinkedHashMap<java.lang.String,Peer> |
peerList
|
private TorrentFile |
torrent
|
private long |
uploaded
|
Fields inherited from class java.lang.Thread |
---|
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
Constructor Summary | |
---|---|
PeerUpdater(byte[] id,
TorrentFile torrent)
|
Method Summary | |
---|---|
void |
addPeerUpdateListener(PeerUpdateListener listener)
Adds a PeerUpdateListener to the list of listeners, enabling communication with this object |
java.util.Map |
contactTracker(byte[] id,
TorrentFile t,
long dl,
long ul,
long left,
java.lang.String event)
Contact the tracker according to the HTTP/HTTPS tracker protocol and using the information in the TorrentFile. |
void |
end()
Stops the update process. |
protected void |
fireUpdateFailed(int error,
java.lang.String message)
Sends a message to all listeners with an error code and a String representing the reason why the last try to contact tracker failed |
protected void |
fireUpdatePeerList(java.util.LinkedHashMap l)
Sends a message to all listeners with a HashMap containg the list of all peers present in the last tracker response |
long |
getDownloaded()
Returns the number of bytes that have been downloaded so far |
java.lang.String |
getEvent()
Returns the current event of the client |
int |
getInterval()
Returns the last interval for updates received from the tracker |
long |
getLeft()
Returns the number of bytes still to download to complete task |
java.util.LinkedHashMap |
getList()
Returns the list of peers in its current state |
int |
getMinInterval()
Returns the last minimal interval for updates received from the tracker |
PeerUpdateListener[] |
getPeerUpdateListeners()
Returns the list of object that are currently listening to this PeerUpdater |
long |
getUploaded()
Returns the number of bytes that have been uploaded so far |
java.util.LinkedHashMap<java.lang.String,Peer> |
processResponse(java.util.Map m)
Process the map representing the tracker response, which should contain either an error message or the peers list and other information such as the interval before next update, aso |
void |
removePeerUpdateListener(PeerUpdateListener listener)
Removes a PeerUpdateListener from the list of listeners |
void |
run()
Thread method that regularly contact the tracker and process its response |
void |
setDownloaded(long dl)
Sets the # of bytes downloaded so far |
void |
setEvent(java.lang.String event)
Sets the current state of the client |
void |
setInterval(int interval)
Sets the interval between tracker update |
void |
setLeft(long left)
Sets the # of bytes still to download |
void |
setListeningPort(int port)
|
void |
setMinInterval(int minInt)
Sets the mininterval between tracker update |
void |
setUploaded(long ul)
Sets the # of bytes uploaded so far |
void |
updateParameters(int dl,
int ul,
java.lang.String event)
Update the parameters for future tracker communication |
Methods inherited from class java.lang.Thread |
---|
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private long downloaded
private boolean end
private java.lang.String event
private boolean first
private byte[] id
private int interval
private long left
private final javax.swing.event.EventListenerList listeners
private int listeningPort
private int minInterval
private java.util.LinkedHashMap<java.lang.String,Peer> peerList
private TorrentFile torrent
private long uploaded
Constructor Detail |
---|
public PeerUpdater(byte[] id, TorrentFile torrent)
Method Detail |
---|
public void addPeerUpdateListener(PeerUpdateListener listener)
listener
- PeerUpdateListenerpublic java.util.Map contactTracker(byte[] id, TorrentFile t, long dl, long ul, long left, java.lang.String event)
id
- byte[]t
- TorrentFiledl
- longul
- longleft
- longevent
- String
public void end()
protected void fireUpdateFailed(int error, java.lang.String message)
error
- intmessage
- Stringprotected void fireUpdatePeerList(java.util.LinkedHashMap l)
l
- LinkedHashMappublic long getDownloaded()
public java.lang.String getEvent()
public int getInterval()
public long getLeft()
public java.util.LinkedHashMap getList()
public int getMinInterval()
public PeerUpdateListener[] getPeerUpdateListeners()
public long getUploaded()
public java.util.LinkedHashMap<java.lang.String,Peer> processResponse(java.util.Map m)
m
- The tracker response as a Map
public void removePeerUpdateListener(PeerUpdateListener listener)
listener
- PeerUpdateListenerpublic void run()
run
in interface java.lang.Runnable
run
in class java.lang.Thread
public void setDownloaded(long dl)
dl
- longpublic void setEvent(java.lang.String event)
event
- Stringpublic void setInterval(int interval)
interval
- intpublic void setLeft(long left)
left
- longpublic void setListeningPort(int port)
public void setMinInterval(int minInt)
minInt
- intpublic void setUploaded(long ul)
ul
- longpublic void updateParameters(int dl, int ul, java.lang.String event)
dl
- intul
- intevent
- String
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |