Methods Summary |
---|
private void | constructBuffer()
buffer = DirectByteBufferPool.getBuffer( DirectByteBuffer.AL_MSG_BT_HAND, 68 );
//buffer.put( DirectByteBuffer.SS_MSG, (byte)PROTOCOL.length() );
//buffer.put( DirectByteBuffer.SS_MSG, PROTOCOL.getBytes() );
//buffer.put( DirectByteBuffer.SS_MSG, reserved_bytes );
//buffer.put( DirectByteBuffer.SS_MSG, datahash_bytes );
//buffer.put( DirectByteBuffer.SS_MSG, peer_id_bytes );
//buffer.flip( DirectByteBuffer.SS_MSG );
|
public Message | deserialize(DirectByteBuffer data, byte version)
if( data == null ) {
throw new MessageException( "[" +getID() + "] decode error: data == null" );
}
if( data.remaining( DirectByteBuffer.SS_MSG ) != 68 ) {
throw new MessageException( "[" +getID() + "] decode error: payload.remaining[" +data.remaining( DirectByteBuffer.SS_MSG )+ "] != 68" );
}
byte[] reserved = new byte[ 8 ];
data.get( DirectByteBuffer.SS_MSG, reserved );
byte[] infohash = new byte[ 20 ];
data.get( DirectByteBuffer.SS_MSG, infohash );
byte[] peerid = new byte[ 20 ];
data.get( DirectByteBuffer.SS_MSG, peerid );
data.returnToPool();
return new ADVHandshake(version);
|
public void | destroy()
if( buffer != null ) buffer.returnToPool();
|
public DirectByteBuffer[] | getData()
if( buffer == null ) {
constructBuffer();
}
return new DirectByteBuffer[]{ buffer };
|
public java.lang.String | getDescription()
if( description == null ) {
description = getID();
}
return description;
|
public java.lang.String | getFeatureID() return ADVMessage.ADV_FEATURE_ID;
|
public int | getFeatureSubID() return ADVMessage.SUBID_ADV_HANDSHAKE;
|
public java.lang.String | getID() return ADVMessage.ID_ADV_HANDSHAKE;
|
public byte[] | getIDBytes() return ADVMessage.ID_ADV_HANDSHAKE_BYTES;
|
public int | getType() return Message.TYPE_PROTOCOL_PAYLOAD;
|
public byte | getVersion() return version;
|