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

AZSessionEnd

public class AZSessionEnd extends Object implements com.aelitis.azureus.core.peermanager.messaging.azureus.AZMessage
Sent when a torrent session ends/fails.

Fields Summary
private final byte
version
private DirectByteBuffer
buffer
private String
description
private final byte[]
infohash
private final String
reason
Constructors Summary
public AZSessionEnd(byte[] infohash, String reason, byte version)

  

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

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

    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 );
    
    byte[] reason_raw = (byte[])root.get( "reason" );
    if( reason_raw == null )  throw new MessageException( "reason_raw == null" );
    String res = new String( reason_raw );
    
    return new AZSessionEnd( hash, res, version );
  
public voiddestroy()

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

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

    if( description == null ) {
      description = getID()+ " for infohash " +ByteFormatter.nicePrint( infohash, true )+ " because " +reason;
    }
    return description;
  
public java.lang.StringgetEndReason()

  return reason;  
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_END;  
public byte[]getIDBytes()

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

  return infohash;  
public intgetType()

  return Message.TYPE_PROTOCOL_PAYLOAD;  
public bytegetVersion()

 return version;