Methods Summary |
---|
public void | addListener(PEPeerListener l)
final PEPeer self =this;
// add a listener to the foreign, then call our listeners when it calls us
PeerListener2 core_listener =
new PeerListener2()
{
public void
eventOccurred(
PeerEvent event )
{
Object data = event.getData();
switch( event.getType() ){
case PeerEvent.ET_STATE_CHANGED:{
l.stateChanged(self, ((Integer)data).intValue());
break;
}
case PeerEvent.ET_BAD_CHUNK:{
Integer[] d = (Integer[])data;
l.sentBadChunk(self, d[0].intValue(), d[1].intValue() );
break;
}
case PeerEvent.ET_ADD_AVAILABILITY:{
l.addAvailability(self, new BitFlags((boolean[])data));
break;
}
case PeerEvent.ET_REMOVE_AVAILABILITY:{
l.removeAvailability(self, new BitFlags((boolean[])data));
break;
}
}
}
};
foreign.addListener( core_listener );
if( peer_listeners == null ){
peer_listeners = new HashMap();
}
peer_listeners.put( l, core_listener );
|
public void | addRateLimiter(com.aelitis.azureus.core.networkmanager.LimitedRateGroup limiter, boolean upload)
network_connection.addRateLimiter( limiter, upload );
|
public void | checkInterested()Nothing to do if called
|
public void | clearAvailabilityAdded()Nothing to do if called
|
public void | clearRequestHint()
|
public void | closeConnection(java.lang.String reason)
try{
foreign.close( reason, false, false );
}finally{
stop();
}
|
protected void | dataReceived()
last_data_received_time = SystemTime.getCurrentTime();
|
public void | doKeepAliveCheck()
|
public void | doPerformanceTuningCheck()
|
public boolean | doTimeoutChecks()
return false;
|
public boolean | equals(java.lang.Object other)
if ( other instanceof PeerForeignDelegate ){
return( foreign.equals(((PeerForeignDelegate)other).foreign ));
}
return( false );
|
public void | generateEvidence(IndentWriter writer)
writer.println( "delegate: ip=" + getIp() + ",tcp=" + getTCPListenPort()+",udp="+getUDPListenPort()+",state=" + foreign.getState()+",foreign=" + foreign );
|
public com.aelitis.azureus.core.peermanager.piecepicker.util.BitFlags | getAvailable()
boolean[] flags = foreign.getAvailable();
if ( bit_flags == null || bit_flags.flags != flags ){
bit_flags = new BitFlags( flags );
}
return( bit_flags );
|
public java.lang.String | getClient()
return( foreign.getClient());
|
public java.lang.String | getClientNameFromExtensionHandshake()return null;
|
public java.lang.String | getClientNameFromPeerID()return null;
|
public int | getConnectionState()
int peer_state = getPeerState();
if ( peer_state == Peer.CONNECTING ){
return( CONNECTION_CONNECTING );
}else if ( peer_state == Peer.HANDSHAKING ){
return( CONNECTION_WAITING_FOR_HANDSHAKE );
}else if ( peer_state == Peer.TRANSFERING ){
return( CONNECTION_FULLY_ESTABLISHED );
}else{
return( CONNECTION_FULLY_ESTABLISHED );
}
|
public int | getConsecutiveNoRequestCount()
return( consecutive_no_requests );
|
public PEPeerControl | getControl()
return((PEPeerControl)manager.getDelegate());
|
public java.lang.Object | getData(java.lang.String key)To retreive arbitrary objects against a peer.
if (data == null) return null;
return data.get(key);
|
public int | getDownloadRateLimitBytesPerSecond() return network_connection.getDownloadLimit();
|
public java.lang.String | getEncryption()
return( "" );
|
public java.util.List | getExpiredRequests()
return( foreign.getExpiredRequests());
|
public byte[] | getHandshakeReservedBytes()
return foreign.getHandshakeReservedBytes();
|
public java.lang.String | getIPHostName()
return( foreign.getIp());
|
public byte[] | getId()
return( foreign.getId());
|
public int | getIncomingRequestCount()
return( 0 );
|
public int[] | getIncomingRequestedPieceNumbers()
return( new int[0] );
|
public java.lang.String | getIp()
return( foreign.getIp());
|
public int | getLastPiece()
return _lastPiece;
|
public PEPeerManager | getManager()
return( manager.getDelegate());
|
public int | getMaxNbRequests()
return( foreign.getMaximumNumberOfRequests());
|
public int | getMessagingMode()
return PEPeer.MESSAGING_EXTERN;
|
public int | getNbRequests()
return( foreign.getNumberOfRequests());
|
public int | getOutboundDataQueueSize()
// don't know, assume all requests are queued and block size
return( getOutgoingRequestCount() * DiskManager.BLOCK_SIZE );
|
public int | getOutgoingRequestCount()
return( foreign.getRequests().size());
|
public int[] | getOutgoingRequestedPieceNumbers()
List l = foreign.getRequests();
int[] res = new int[l.size()];
for (int i=0;i<l.size();i++){
res[i] = ((PeerReadRequest)l.get(i)).getPieceNumber();
}
return( res );
|
public PeerItem | getPeerItemIdentity()
return PeerItemFactory.createPeerItem(
foreign.getIp(),
foreign.getTCPListenPort(),
PeerItemFactory.PEER_SOURCE_PLUGIN,
PeerItemFactory.HANDSHAKE_TYPE_PLAIN,
foreign.getUDPListenPort(),
PeerItemFactory.CRYPTO_LEVEL_1,
0 );
|
public java.lang.String | getPeerSource()
return( PEPeerSource.PS_PLUGIN );
|
public int | getPeerState()
int peer_state = foreign.getState();
return( peer_state );
|
public int | getPercentDoneInThousandNotation()
return foreign.getPercentDoneInThousandNotation();
|
public int | getPercentDoneOfCurrentIncomingRequest()
return( foreign.getPercentDoneOfCurrentIncomingRequest());
|
public int | getPercentDoneOfCurrentOutgoingRequest()
return( foreign.getPercentDoneOfCurrentOutgoingRequest());
|
public org.gudy.azureus2.plugins.network.Connection | getPluginConnection()
return( foreign.getConnection());
|
public int | getPort()
return( foreign.getPort());
|
public int[] | getPriorityOffsets()
return( foreign.getPriorityOffsets());
|
public int[] | getRequestHint()
return null;
|
public int | getRequestIndex(org.gudy.azureus2.core3.disk.DiskManagerReadRequest request)
return( foreign.getRequests().indexOf( request ));
|
public int | getReservedPieceNumber()
return( reserved_piece );
|
public long | getSnubbedTime()
return foreign.getSnubbedTime();
|
public PEPeerStats | getStats()
return( ((PeerStatsImpl)foreign.getStats()).getDelegate());
|
public com.aelitis.azureus.core.peermanager.messaging.Message[] | getSupportedMessages()
org.gudy.azureus2.plugins.messaging.Message[] plug_msgs = foreign.getSupportedMessages();
Message[] core_msgs = new Message[ plug_msgs.length ];
for( int i=0; i < plug_msgs.length; i++ ) {
core_msgs[i] = new MessageAdapter( plug_msgs[i] );
}
return core_msgs;
|
public int | getTCPListenPort() return foreign.getTCPListenPort();
|
public long | getTimeSinceConnectionEstablished()
long now = SystemTime.getCurrentTime();
if ( now > create_time ){
return( now - create_time );
}
return( 0 );
|
public long | getTimeSinceGoodDataReceived()
if (last_data_received_time ==-1)
return -1; // never received
long now =SystemTime.getCurrentTime();
long time_since =now -last_data_received_time;
if (time_since <0)
{ // time went backwards
last_data_received_time =now;
time_since =0;
}
return time_since;
|
public long | getTimeSinceLastDataMessageReceived()
if (last_data_message_received_time ==-1)
return -1; //never received
final long now =SystemTime.getCurrentTime();
if (last_data_message_received_time <now)
last_data_message_received_time =now; //time went backwards
return now -last_data_message_received_time;
|
public long | getTimeSinceLastDataMessageSent()
return 0;
|
public int | getUDPListenPort() return foreign.getUDPListenPort();
|
public int | getUDPNonDataListenPort() return( foreign.getUDPNonDataListenPort());
|
public int | getUniqueAnnounce()
return -1;
|
public int | getUploadHint()
return 0;
|
public int | getUploadRateLimitBytesPerSecond() return network_connection.getUploadLimit();
|
public boolean | hasReceivedBitField()
return( true );
|
public int | hashCode()
return( foreign.hashCode());
|
public boolean | isAvailabilityAdded()Apaprently nothing significant to do if calledreturn false;
|
public boolean | isChokedByMe()
return( foreign.isChoking());
|
public boolean | isChokingMe()
return( foreign.isChoked());
|
public boolean | isDownloadPossible()
return foreign.isDownloadPossible();
|
public boolean | isIncoming()
return( foreign.isIncoming());
|
public boolean | isInterested()
return( foreign.isInterested());
|
public boolean | isInteresting()
return( foreign.isInteresting());
|
public boolean | isLANLocal()
return( AddressUtils.isLANLocalAddress( foreign.getIp()) == AddressUtils.LAN_LOCAL_YES );
|
public boolean | isOptimisticUnchoke()
return( foreign.isOptimisticUnchoke());
|
public boolean | isPieceAvailable(int pieceNumber)
return foreign.isPieceAvailable(pieceNumber);
|
public boolean | isSeed()
return( foreign.isSeed());
|
public boolean | isSnubbed()
return( foreign.isSnubbed());
|
public boolean | isStalledPendingLoad()return( false );
|
public boolean | isTCP()
return( true );
|
public PEPeerTransport | reconnect() return null;
|
public void | removeListener(PEPeerListener l)
if ( peer_listeners != null ){
Object core_listener = peer_listeners.remove( l );
if ( core_listener != null ){
if( core_listener instanceof PeerListener ) {
foreign.removeListener((PeerListener)core_listener );
}else{
foreign.removeListener((PeerListener2)core_listener );
}
}
}
|
public void | removeRateLimiter(com.aelitis.azureus.core.networkmanager.LimitedRateGroup limiter, boolean upload)
network_connection.removeRateLimiter( limiter, upload );
|
public org.gudy.azureus2.core3.disk.DiskManagerReadRequest | request(int pieceNumber, int pieceOffset, int pieceLength)
DiskManagerReadRequest request = manager.getDelegate().getDiskManager().createReadRequest( pieceNumber, pieceOffset, pieceLength );
if ( foreign.addRequest( request )){
return( request );
}else{
return( null );
}
|
public void | requestAllocationComplete()
foreign.requestAllocationComplete();
|
public boolean | requestAllocationStarts(int[] base_priorities)
return( foreign.requestAllocationStarts( base_priorities ));
|
public void | sendBadPiece(int piece_number)
|
public void | sendCancel(org.gudy.azureus2.core3.disk.DiskManagerReadRequest request)
foreign.cancelRequest( request );
|
public void | sendChoke()Should never be called
|
public void | sendHave(int piece)Nothing to do if called
|
public boolean | sendRequestHint(int piece_number, int offset, int length, int life)
return( false );
|
public void | sendUnChoke()Should never be called
|
public void | setConsecutiveNoRequestCount(int num)
consecutive_no_requests = num;
|
public void | setData(java.lang.String key, java.lang.Object value)To store arbitrary objects against a peer.
try{
this_mon.enter();
if (data == null) {
data = new HashMap();
}
if (value == null) {
if (data.containsKey(key))
data.remove(key);
} else {
data.put(key, value);
}
}finally{
this_mon.exit();
}
|
public void | setDownloadRateLimitBytesPerSecond(int bytes) network_connection.setDownloadLimit( bytes );
|
public void | setHaveAggregationEnabled(boolean enabled)
|
public void | setLastPiece(int pieceNumber)
_lastPiece =pieceNumber;
|
public void | setOptimisticUnchoke(boolean is_optimistic)
foreign.setOptimisticUnchoke( is_optimistic );
|
public void | setReservedPieceNumber(int pieceNumber)
reserved_piece = pieceNumber;
|
public void | setSnubbed(boolean b)
foreign.setSnubbed( b );
|
public void | setUniqueAnnounce(int uniquePieceNumber)
|
public void | setUploadHint(int timeToSpread)
|
public void | setUploadRateLimitBytesPerSecond(int bytes) network_connection.setUploadLimit( bytes );
|
public void | start()
NetworkManager.getSingleton().startTransferProcessing( network_connection );
NetworkManager.getSingleton().upgradeTransferProcessing( network_connection );
|
protected void | stop()
NetworkManager.getSingleton().stopTransferProcessing( network_connection );
|
public boolean | supportsMessaging()
return foreign.supportsMessaging();
|
public boolean | transferAvailable()
return( foreign.isTransferAvailable());
|
public void | updatePeerExchange()
|