FileDocCategorySizeDatePackage
BTTorrentSession.javaAPI DocAzureus 3.0.3.45700Sun Mar 04 21:08:16 GMT 2007com.aelitis.azureus.core.peermanager.download.session.impl

BTTorrentSession

public class BTTorrentSession extends Object implements TorrentSession

Fields Summary
private final TorrentSessionListener
listener
private final com.aelitis.azureus.core.peermanager.connection.AZPeerConnection
peer
private final IncomingMessageQueue.MessageQueueListener
incoming_q_listener
private final OutgoingMessageQueue.MessageQueueListener
sent_message_listener
Constructors Summary
public BTTorrentSession(com.aelitis.azureus.core.peermanager.connection.AZPeerConnection peer, TorrentSessionListener listener)

  
  
  
         
    this.peer = peer;
    this.listener = listener;
    
    peer.getNetworkConnection().getIncomingMessageQueue().registerQueueListener( incoming_q_listener );
    peer.getNetworkConnection().getOutgoingMessageQueue().registerQueueListener( sent_message_listener );
    
    listener.sessionIsEstablished();  //notify of readiness
  
Methods Summary
public voidendSession(java.lang.String reason)

    peer.getNetworkConnection().getIncomingMessageQueue().cancelQueueListener( incoming_q_listener );
    peer.getNetworkConnection().getOutgoingMessageQueue().cancelQueueListener( sent_message_listener );
  
public voidsendSessionBitfield(org.gudy.azureus2.core3.util.DirectByteBuffer bitfield)

    peer.getNetworkConnection().getOutgoingMessageQueue().addMessage( new BTBitfield( bitfield, (byte)1 ), false );
  
public voidsendSessionCancel(int piece_number, int piece_offset, int length)

    peer.getNetworkConnection().getOutgoingMessageQueue().addMessage( new BTCancel( piece_number, piece_offset, length, (byte)1 ), false );
  
public voidsendSessionHave(int[] piece_numbers)

    for( int i=0; i < piece_numbers.length; i++ ) { 
      peer.getNetworkConnection().getOutgoingMessageQueue().addMessage( new BTHave( piece_numbers[i], (byte)1 ), false );
    }
  
public java.lang.ObjectsendSessionPiece(int piece_number, int piece_offset, org.gudy.azureus2.core3.util.DirectByteBuffer data)

    BTPiece piece = new BTPiece( piece_number, piece_offset, data, (byte)1 );
    peer.getNetworkConnection().getOutgoingMessageQueue().addMessage( piece, false );
    return piece;
  
public voidsendSessionRequest(byte unchoke_id, int piece_number, int piece_offset, int length)

    peer.getNetworkConnection().getOutgoingMessageQueue().addMessage( new BTRequest( piece_number, piece_offset, length, (byte)1 ), false );