Methods Summary |
---|
protected void | addMessage(com.aelitis.azureus.core.peermanager.messaging.Message message)
synchronized( messages ){
messages.add( message );
}
http_connection.readWakeup();
|
public java.nio.ByteBuffer | destroy()
paused = true;
destroyed = true;
if ( http_connection != null ){
http_connection.destroy();
}
try{
for( int i=0; i<messages.size(); i++ ){
Message msg = (Message)messages.get( i );
msg.destroy();
}
}catch( IndexOutOfBoundsException e ){
// as access to messages_last_read isn't synchronized we can get this error if we destroy the
// decoder in parallel with messages being removed. We don't really want to synchornized access
// to this so we'll take the hit here
}
messages.clear();
return( null );
|
public int | getDataBytesDecoded()
return( 0 );
|
public int | getPercentDoneOfCurrentMessage()
return( 0 );
|
public int | getProtocolBytesDecoded()
return( protocol_bytes_read );
|
protected int | getQueueSize()
return( messages.size());
|
public void | pauseDecoding()
paused = true;
|
protected void | pauseInternally()
paused_internally = true;
|
public int | performStreamDecode(com.aelitis.azureus.core.networkmanager.Transport transport, int max_bytes)
// before we start message processing we should have had the connection bound
if ( http_connection == null ){
Debug.out( "connection not yet assigned" );
throw( new IOException( "Internal error - connection not yet assigned" ));
}
// System.out.println( "performStreamDecode" );
protocol_bytes_read = 0;
if ( paused_internally ){
return( 0 );
}
if ( header_ready ){
header_ready = false;
int len = header_so_far.length();
http_connection.decodeHeader( this, header_so_far.toString());
header_so_far.setLength(0);
return( len );
}else{
int rem = max_bytes;
byte[] bytes = new byte[1];
ByteBuffer bb = ByteBuffer.wrap( bytes );
ByteBuffer[] bbs = { bb };
while( rem > 0 && !( paused || paused_internally )){
if ( transport.read( bbs,0, 1 ) == 0 ){
break;
}
rem--;
protocol_bytes_read++;
bb.flip();
char c = (char)(bytes[0]&0xff);
header_so_far.append( c );
if ( header_so_far.length() > MAX_HEADER ){
throw( new IOException( "HTTP header exceeded maximum of " + MAX_HEADER ));
}
if ( c == '\n" ){
String header_str = header_so_far.toString();
if ( header_str.endsWith( NL + NL )){
http_connection.decodeHeader( this, header_str );
header_so_far.setLength(0);
}
}
}
return( max_bytes - rem );
}
|
public com.aelitis.azureus.core.peermanager.messaging.Message[] | removeDecodedMessages()
synchronized( messages ){
if ( messages.isEmpty()){
return null;
}
Message[] msgs = (Message[])messages.toArray( new Message[messages.size()] );
messages.clear();
return( msgs );
}
|
public void | resumeDecoding()
if ( !destroyed ){
paused = false;
}
|
public void | setConnection(HTTPNetworkConnection _http_connection)
http_connection = _http_connection;
if ( destroyed ){
http_connection.destroy();
}
|