FileDocCategorySizeDatePackage
AZSessionAck.javaAPI DocAzureus 3.0.3.43851Sun Mar 04 21:08:16 GMT 2007com.aelitis.azureus.core.peermanager.messaging.azureus.session

AZSessionAck

public class AZSessionAck extends Object implements com.aelitis.azureus.core.peermanager.messaging.azureus.AZMessage
Sent as reply to torrent session initiation request.

Fields Summary
private final byte
version
private DirectByteBuffer
buffer
private String
description
private final int
session_id
private final byte[]
infohash
private final Map
session_info
Constructors Summary
public AZSessionAck(byte[] infohash, int local_session_id, Map session_info, byte version)

  

             
    this.session_id = local_session_id;
    this.infohash = infohash;
    this.session_info = session_info;
    this.version = version;
  
Methods Summary
public Messagedeserialize(DirectByteBuffer data, byte version)

    
    Map root = MessagingUtil.convertBencodedByteStreamToPayload( data, 20, getID() );

    Long id = (Long)root.get( "session_id" );
    if( id == null ) throw new MessageException( "id == null" );
    int sid = id.intValue();
    
    byte[] hash = (byte[])root.get( "infohash" );
    if( hash == null )  throw new MessageException( "hash == null" );
    if( hash.length != 20 )  throw new MessageException( "hash.length != 20: " +hash.length );
    
    Map info = (Map)root.get( "info" );
    
    return new AZSessionAck( hash, sid, info, version );
  
public voiddestroy()

    if( buffer != null )  buffer.returnToPool();
  
public DirectByteBuffer[]getData()

    if( buffer == null ) {
      Map payload_map = new HashMap();
      
      payload_map.put( "session_id", new Long(session_id) );
      payload_map.put( "infohash", infohash );
      payload_map.put( "info", session_info );
      
      buffer = MessagingUtil.convertPayloadToBencodedByteStream( payload_map, DirectByteBuffer.AL_MSG );
    }
    
    return new DirectByteBuffer[]{ buffer };
  
public java.lang.StringgetDescription()

    if( description == null ) {
      description = getID()+ " session id " +session_id+ " for infohash " +ByteFormatter.nicePrint( infohash, true );
    }
    return description;
  
public java.lang.StringgetFeatureID()

  throw new RuntimeException( "not implemented" );  
public intgetFeatureSubID()

  throw new RuntimeException( "not implemented" );  
public java.lang.StringgetID()

  return AZMessage.ID_AZ_SESSION_ACK;  
public byte[]getIDBytes()

  return AZMessage.ID_AZ_SESSION_ACK_BYTES;  
public byte[]getInfoHash()

  return infohash;  
public intgetSessionID()

  return session_id;  
public java.util.MapgetSessionInfo()

  return session_info;  
public intgetType()

  return Message.TYPE_PROTOCOL_PAYLOAD;  
public bytegetVersion()

 return version;