FileDocCategorySizeDatePackage
BTMessageManager.javaAPI DocAzureus 3.0.3.44876Sun Mar 04 21:08:18 GMT 2007org.gudy.azureus2.plugins.messaging.bittorrent

BTMessageManager

public class BTMessageManager extends Object

Fields Summary
public static final String
ID_BTMESSAGE_REQUEST
public static final String
ID_BTMESSAGE_CANCEL
public static final String
ID_BTMESSAGE_PIECE
public static final String
ID_BTMESSAGE_UNCHOKE
Constructors Summary
Methods Summary
public static MessagecreateCoreBTCancel(int piece_number, int piece_offset, int length)
Create a core BT Cancel message instance.

param
piece_number
param
piece_offset
param
length
return
core message wrapped in an adapter

    return new MessageAdapter( new BTCancel( piece_number, piece_offset, length, (byte)1 ) );    
  
public static BTMessageCancelcreateCoreBTCancelAdaptation(Message core_made_message)
Translate the given core-made BT Cancel message into a specific plugin message adaptation.

param
core_made_message to translate
return
adapted plugin message

    //the message was originally created by core and wrapped
    com.aelitis.azureus.core.peermanager.messaging.Message core_msg = ((MessageAdapter)core_made_message).getCoreMessage();
    
    if( core_msg.getID().equals( BTMessage.ID_BT_CANCEL ) ) {
      return new BTMessageCancel( core_msg );
    }
    
    return null;
  
public static MessagecreateCoreBTPiece(int piece_number, int piece_offset, java.nio.ByteBuffer data)
Create a core BT Piece message instance.

param
piece_number
param
piece_offset
param
data
return
core message wrapped in an adapter

    return new MessageAdapter( new BTPiece( piece_number, piece_offset, new DirectByteBuffer( data ), (byte)1 ) );    
  
public static BTMessagePiececreateCoreBTPieceAdaptation(Message core_made_message)
Translate the given core-made BT Piece message into a specific plugin message adaptation.

param
core_made_message to translate
return
adapted plugin message

    //the message was originally created by core and wrapped
    com.aelitis.azureus.core.peermanager.messaging.Message core_msg = ((MessageAdapter)core_made_message).getCoreMessage();
    
    if( core_msg.getID().equals( BTMessage.ID_BT_PIECE ) ) {
      return new BTMessagePiece( core_msg );
    }
    
    return null;
  
public static MessagecreateCoreBTRequest(int piece_number, int piece_offset, int length)
Create a core BT Request message instance.

param
piece_number
param
piece_offset
param
length
return
core message wrapped in an adapter

    return new MessageAdapter( new BTRequest( piece_number, piece_offset, length, (byte)1 ) );    
  
public static BTMessageRequestcreateCoreBTRequestAdaptation(Message core_made_message)
Translate the given core-made BT Request message into a specific plugin message adaptation.

param
core_made_message to translate
return
adapted plugin message

  

                          
         
    //the message was originally created by core and wrapped
    com.aelitis.azureus.core.peermanager.messaging.Message core_msg = ((MessageAdapter)core_made_message).getCoreMessage();
    
    if( core_msg.getID().equals( BTMessage.ID_BT_REQUEST ) ) {
      return new BTMessageRequest( core_msg );
    }
    
    return null;