Package com.aelitis.azureus.core.peermanager.messaging

Examples of com.aelitis.azureus.core.peermanager.messaging.MessageException


    DirectByteBuffer   data,
    byte        version )
   
     throws MessageException
  {
    throw( new MessageException( "not imp" ));
  }
View Full Code Here


    DirectByteBuffer  data,
    byte         version )
 
    throws MessageException
  {
    throw( new MessageException( "not imp" ));
  }
View Full Code Here

 
  public DirectByteBuffer[] getData() {  return new DirectByteBuffer[] {}}
   
  public Message deserialize( DirectByteBuffer data, byte version ) throws MessageException {
    if( data != null && data.hasRemaining( DirectByteBuffer.SS_MSG ) ) {
      throw new MessageException( "[" +getID() +"] decode error: payload not empty" );
    }
   
    if( data != null data.returnToPool();
   
    return new BTInterested(version);
View Full Code Here

 
 
 
  public Message deserialize( DirectByteBuffer data, byte version ) throws MessageException {   
    if( data == null ) {
      throw new MessageException( "[" +getID() + "] decode error: data == null" );
    }
   
    if( data.remaining( DirectByteBuffer.SS_MSG ) < 8 ) {
      throw new MessageException( "[" +getID()+ "] decode error: payload.remaining[" +data.remaining( DirectByteBuffer.SS_MSG )+ "] < 8" );
    }
   
    int number = data.getInt( DirectByteBuffer.SS_MSG );
    if( number < 0 ) {
      throw new MessageException( "[" +getID() +"] decode error: number < 0" );
    }
   
    int offset = data.getInt( DirectByteBuffer.SS_MSG );
    if( offset < 0 ) {
      throw new MessageException( "[" +getID() + "] decode error: offset < 0" );
    }
   
    return new BTPiece( number, offset, data, version );
  }
View Full Code Here

  }
 
 
  public Message deserialize( DirectByteBuffer data, byte version ) throws MessageException {
    if( data == null ) {
      throw new MessageException( "[" +getID() +"] decode error: data == null" );
    }
   
    if( data.remaining( DirectByteBuffer.SS_MSG ) != 4 ) {
      throw new MessageException( "[" +getID() "] decode error: payload.remaining[" +data.remaining( DirectByteBuffer.SS_MSG )+ "] != 12" );
    }
   
    int num = data.getInt( DirectByteBuffer.SS_MSG );
    if( num < 0 ) {
      throw new MessageException( "[" +getID() + "] decode error: num < 0" );
    }
   
    data.returnToPool();
   
    return new BTSuggestPiece( num, version );
View Full Code Here

 
  public DirectByteBuffer[] getData() {  return new DirectByteBuffer[] {}}
 
  public Message deserialize( DirectByteBuffer data, byte version ) throws MessageException {
    if( data != null && data.hasRemaining( DirectByteBuffer.SS_MSG ) ) {
      throw new MessageException( "[" +getID() + "] decode error: payload not empty [" +data.remaining(DirectByteBuffer.SS_MSG)+ "]" );
    }
   
    if( data != null data.returnToPool();
   
    return new BTChoke(version);
View Full Code Here

 
  public DirectByteBuffer[] getData() {  return buffer;  }

  public Message deserialize( DirectByteBuffer data, byte version ) throws MessageException {   
    if( data == null ) {
      throw new MessageException( "[" +getID() +"] decode error: data == null" );
    }
       
    return new BTBitfield( data, version );
  }
View Full Code Here

 
  public DirectByteBuffer[] getData() {  return new DirectByteBuffer[] {}}
 
  public Message deserialize( DirectByteBuffer data, byte version ) throws MessageException {   
    if( data != null && data.hasRemaining( DirectByteBuffer.SS_MSG ) ) {
      throw new MessageException( "[" +getID() +"] decode error: payload not empty" );
    }
   
    if( data != null data.returnToPool();
   
    return new BTUninterested(version);
View Full Code Here

  }
 
 
  public Message deserialize( DirectByteBuffer data, byte version ) throws MessageException {  
    if( data == null ) {
      throw new MessageException( "[" +getID() + "] decode error: data == null" );
    }
   
    if( data.remaining( DirectByteBuffer.SS_MSG ) != 12 ) {
      throw new MessageException( "[" +getID() + "] decode error: payload.remaining[" +data.remaining( DirectByteBuffer.SS_MSG )+ "] != 12" );
    }
   
    int num = data.getInt( DirectByteBuffer.SS_MSG );
    if( num < 0 ) {
      throw new MessageException( "[" +getID() + "] decode error: num < 0" );
    }
   
    int offset = data.getInt( DirectByteBuffer.SS_MSG );
    if( offset < 0 ) {
      throw new MessageException( "[" +getID() + "] decode error: offset < 0" );
    }
   
    int length = data.getInt( DirectByteBuffer.SS_MSG );
    if( length < 0 ) {
      throw new MessageException( "[" +getID() + "] decode error: length < 0" );
    }
   
    data.returnToPool();
   
    return new BTRejectRequest( num, offset, length, version );
View Full Code Here

 
  public Message deserialize( DirectByteBuffer data, byte version ) throws MessageException {
    Map root = MessagingUtil.convertBencodedByteStreamToPayload( data, 100, getID() );

    byte[] id = (byte[])root.get( "identity" );
    if( id == null throw new MessageException( "id == null" );
    if( id.length != 20 throw new MessageException( "id.length != 20: " +id.length );
   
    byte[] session = (byte[])root.get("session");
    byte[] reconnect = (byte[])root.get("reconn");
     
    byte[] raw_name = (byte[])root.get( "client" );
    if( raw_name == null throw new MessageException( "raw_name == null" );
    String name = new String( raw_name );

    byte[] raw_ver = (byte[])root.get( "version" );
    if( raw_ver == null throw new MessageException( "raw_ver == null" );
    String client_version = new String( raw_ver );

    Long tcp_lport = (Long)root.get( "tcp_port" );
    if( tcp_lport == null ) {  //old handshake
      tcp_lport = new Long( 0 );
    }

    Long udp_lport = (Long)root.get( "udp_port" );
    if( udp_lport == null ) {  //old handshake
      udp_lport = new Long( 0 );
    }

    Long udp2_lport = (Long)root.get( "udp2_port" );
    if( udp2_lport == null ) {  //old handshake
      udp2_lport = udp_lport;
    }
   
    Long h_type = (Long)root.get( "handshake_type" );
    if( h_type == null ) {  //only 2307+ send type
      h_type = new Long( HANDSHAKE_TYPE_PLAIN );
    }
   
    InetAddress ipv6 = null;
    if(root.get("ipv6") instanceof byte[])
  {
    try
    {
      InetAddress.getByAddress((byte[]) root.get("ipv6"));
    } catch (Exception e)
    {
     
    }
  }

    List raw_msgs = (List) root.get("messages");
    if (raw_msgs == nullthrow new MessageException("raw_msgs == null");

    String[] ids = new String[raw_msgs.size()];
    byte[] vers = new byte[raw_msgs.size()];

    int pos = 0;

    for (Iterator i = raw_msgs.iterator(); i.hasNext();) {
      Map msg = (Map) i.next();

      byte[] mid = (byte[]) msg.get("id");
      if (mid == nullthrow new MessageException("mid == null");
      ids[pos] = new String(mid);

      byte[] ver = (byte[]) msg.get("ver");
      if (ver == nullthrow new MessageException("ver == null");
     
      if (ver.length != 1throw new MessageException("ver.length != 1");
      vers[pos] = ver[0];

      pos++;
    }
   
View Full Code Here

TOP

Related Classes of com.aelitis.azureus.core.peermanager.messaging.MessageException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.