org.klomp.snark
Class PeerState

java.lang.Object
  extended by org.klomp.snark.PeerState

 class PeerState
extends java.lang.Object


Field Summary
(package private)  BitField bitfield
           
(package private)  boolean choked
           
(package private)  boolean choking
           
(package private)  long downloaded
           
(package private)  PeerConnectionIn in
           
(package private)  boolean interested
           
(package private)  boolean interesting
           
(package private)  PeerListener listener
           
(package private)  MetaInfo metainfo
           
(package private)  PeerConnectionOut out
           
static int PARTSIZE
           
(package private)  Peer peer
           
(package private)  Request pendingRequest
           
(package private)  long uploaded
           
 
Constructor Summary
PeerState(Peer peer, PeerListener listener, MetaInfo metainfo, PeerConnectionIn in, PeerConnectionOut out)
           
 
Method Summary
(package private)  void bitfieldMessage(byte[] bitmap)
           
(package private)  void cancelMessage(int piece, int begin, int length)
           
(package private)  void chokeMessage(boolean choke)
           
(package private)  Request getOutstandingRequest(int piece, int begin, int length)
          Called when a piece message is being processed by the incoming connection.
(package private)  Request getPartialRequest()
           
(package private)  int[] getRequestedPieces()
           
(package private)  void haveMessage(int piece)
           
(package private)  void havePiece(int piece)
           
(package private)  void interestedMessage(boolean interest)
           
(package private)  void keepAlive()
           
(package private)  void keepAliveMessage()
           
(package private)  void pieceMessage(Request req)
          Called when a partial piece request has been handled by PeerConnectionIn.
(package private)  void requestMessage(int piece, int begin, int length)
           
(package private)  void retransmitRequests()
           
(package private)  void setChoking(boolean choke)
           
(package private)  void setInteresting(boolean interest)
           
(package private)  void unknownMessage(int type, byte[] bs)
           
(package private)  void uploaded(int size)
          Called when some bytes have left the outgoing connection.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

peer

final Peer peer

listener

final PeerListener listener

metainfo

final MetaInfo metainfo

interesting

boolean interesting

choking

boolean choking

interested

boolean interested

choked

boolean choked

downloaded

long downloaded

uploaded

long uploaded

bitfield

BitField bitfield

in

final PeerConnectionIn in

out

final PeerConnectionOut out

PARTSIZE

public static final int PARTSIZE
See Also:
Constant Field Values

pendingRequest

Request pendingRequest
Constructor Detail

PeerState

PeerState(Peer peer,
          PeerListener listener,
          MetaInfo metainfo,
          PeerConnectionIn in,
          PeerConnectionOut out)
Method Detail

keepAliveMessage

void keepAliveMessage()

chokeMessage

void chokeMessage(boolean choke)

interestedMessage

void interestedMessage(boolean interest)

haveMessage

void haveMessage(int piece)

bitfieldMessage

void bitfieldMessage(byte[] bitmap)

requestMessage

void requestMessage(int piece,
                    int begin,
                    int length)

uploaded

void uploaded(int size)
Called when some bytes have left the outgoing connection. XXX - Should indicate whether it was a real piece or overhead.


pieceMessage

void pieceMessage(Request req)
Called when a partial piece request has been handled by PeerConnectionIn.


getOutstandingRequest

Request getOutstandingRequest(int piece,
                              int begin,
                              int length)
Called when a piece message is being processed by the incoming connection. Returns null when there was no such request. It also requeues/sends requests when it thinks that they must have been lost.


getPartialRequest

Request getPartialRequest()

getRequestedPieces

int[] getRequestedPieces()

cancelMessage

void cancelMessage(int piece,
                   int begin,
                   int length)

unknownMessage

void unknownMessage(int type,
                    byte[] bs)

havePiece

void havePiece(int piece)

setInteresting

void setInteresting(boolean interest)

setChoking

void setChoking(boolean choke)

keepAlive

void keepAlive()

retransmitRequests

void retransmitRequests()