|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectgps.protocol.BT.BTSocket
public class BTSocket
BT socket deals with lower level connection issue
| Field Summary | |
|---|---|
static int |
CONNECTION_KEEP_ALIVE
keep alive time |
static int |
CONNECTION_TIMEOUT
connection timeout |
boolean |
mAmChoking
I chocked the other side |
boolean |
mAmInterested
I'm interested in their file |
int |
mBegin
offset within a downloading piece |
boolean[] |
mBitField
bit field of that peer |
boolean |
mClosed
if closed, set up the mClosed flag, and remove from hashmap |
BTConnection |
mConnection
lower level connection |
BTSocket |
mCounterpart
the connection at the other side |
boolean |
mDownloading
downloading or not |
int |
mDownloadLeft
bytes left within this block |
BTEvent |
mEstimateFinish
estimate finish event |
java.util.LinkedList |
mInBandwidthHistory
in bandwidth history |
BTEvent |
mKeepAlive
keep alive event |
BTEvent |
mKeepAliveMsg
the keep alive message to be sent |
int |
mLength
length of the current downloading block |
java.util.LinkedList |
mOutBandwidthHistory
out bandwidth history |
boolean |
mPeerChoking
the other side chocked me |
boolean |
mPeerInterested
the other side is interested at my file |
float |
mPreviousPercent
previous finished percent |
int |
mRequestingPieceIndex
the piece that I'm interested, this variable is set when request is sent |
BTEvent |
mRequestTimeout
request time out event |
BTSession |
mSession
reference back to the session to which this connection belongs |
double |
mStartTime
start time for this downloading bandwidth |
BTEvent |
mTimeout
connection time out event |
boolean |
mUploading
uploading or not |
int |
mUploadingPieceIndex
the current uploading piece index |
static int |
REQUEST_TIMEOUT
request timeout |
| Constructor Summary | |
|---|---|
BTSocket(BTSession s)
constructs a new bt socket object |
|
| Method Summary | |
|---|---|
void |
adjustInBandwidth(double adj)
adjusts bandwidth during download, called by counterpart |
void |
adjustOutBandwidth(double adj)
adjust out bandwidth |
double |
calcInAverageSince(double time)
calculate average input bandwidth since a time spot |
double |
calcOutAverageSince(double time)
calculate average output bandwidth since a time spot |
java.util.ArrayList |
comparePieces()
compare piece between two peers at both end of the connection |
boolean |
handle(SimEvent e)
process event sent to this connection |
void |
handleBlockFinished(BTEvent e)
when a block is finished downloading, this event is triggered |
void |
handleKeepAlive(BTEvent e)
handles keep alive event |
void |
handleRequestTimeout(BTEvent e)
handles request timeout event |
java.lang.String |
toString()
gets string description |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final int REQUEST_TIMEOUT
public static final int CONNECTION_TIMEOUT
public static final int CONNECTION_KEEP_ALIVE
public boolean mAmChoking
public boolean mPeerChoking
public boolean mPeerInterested
public boolean mAmInterested
public boolean[] mBitField
public boolean mClosed
public BTSession mSession
public BTSocket mCounterpart
public boolean mUploading
public int mUploadingPieceIndex
public boolean mDownloading
public int mRequestingPieceIndex
public int mBegin
public int mLength
public double mStartTime
public int mDownloadLeft
public float mPreviousPercent
public BTEvent mTimeout
public BTEvent mKeepAlive
public BTEvent mKeepAliveMsg
public BTEvent mEstimateFinish
public BTEvent mRequestTimeout
public BTConnection mConnection
public java.util.LinkedList mInBandwidthHistory
public java.util.LinkedList mOutBandwidthHistory
| Constructor Detail |
|---|
public BTSocket(BTSession s)
s - session this socket belongs to| Method Detail |
|---|
public boolean handle(SimEvent e)
handle in interface SimEventHandlere - the event object with some parameters in it
public void handleRequestTimeout(BTEvent e)
e - the event objectpublic void handleKeepAlive(BTEvent e)
e - the event objectpublic java.util.ArrayList comparePieces()
public void handleBlockFinished(BTEvent e)
e - the event objectpublic void adjustInBandwidth(double adj)
adj - the adjustment amountpublic void adjustOutBandwidth(double adj)
adj - the adjustment amountpublic double calcInAverageSince(double time)
time - time spot
public double calcOutAverageSince(double time)
time - time spot
public java.lang.String toString()
toString in class java.lang.Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||