Methods Summary |
---|
public void | close(java.lang.Throwable reason)
ClientMessage[] messages = null;
try{ msg_mon.enter();
if ( closed ){
return;
}
closed = true;
if( !sending_msgs.isEmpty() ) {
messages = (ClientMessage[])sending_msgs.toArray( new ClientMessage[sending_msgs.size()] );
}
}
finally{ msg_mon.exit(); }
if( messages != null ) {
if ( reason == null ){
reason = new Exception( "Connection closed" );
}
for( int i=0; i < messages.length; i++ ) {
ClientMessage msg = messages[i];
msg.reportFailed( reason );
}
}
decoder.destroy();
out_queue.destroy();
if( parent_transport != null ) {
parent_transport.close( "Tidy close"); //have the parent do the close if possible
}
else {
light_transport.close("Tidy close");
}
|
public void | closePending()Marks the socket as complete and ready to undergo any close-delay prior to it being closed
by the server
last_activity_time = System.currentTimeMillis();
close_pending = true;
|
public java.lang.Throwable | getClosingReason()
return( closing_reason );
|
public java.lang.String | getDebugString() return debug_string;
|
public long | getLastActivityTime()Get the last time this connection had read or write activity. return last_activity_time;
|
public boolean | getLastReadMadeProgress()
return( decoder.getLastReadMadeProgress());
|
public boolean | getLastWriteMadeProgress()
return( last_write_made_progress );
|
public java.nio.channels.SocketChannel | getSocketChannel() return ((TransportEndpointTCP)light_transport.getTransportEndpoint()).getSocketChannel();
|
public java.lang.Object | getUserData(java.lang.Object key)
Map m = user_data;
if ( m == null ){
return( null );
}
return( m.get(key));
|
public boolean | isClosePending()
return( close_pending );
|
public com.aelitis.azureus.core.peermanager.messaging.Message[] | readMessages()Get any messages read from the client.
int bytes_read = decoder.performStreamDecode( light_transport, 1024*1024 );
if( bytes_read > 0 ) last_activity_time = System.currentTimeMillis();
return decoder.removeDecodedMessages();
|
public void | resetLastActivityTime()Reset the last activity time to the current time. last_activity_time = System.currentTimeMillis();
|
public void | sendMessage(ClientMessage client_msg, com.aelitis.azureus.core.peermanager.messaging.Message msg)
try{ msg_mon.enter();
sending_msgs.add( client_msg );
}
finally{ msg_mon.exit(); }
out_queue.registerQueueListener( new OutgoingMessageQueue.MessageQueueListener() {
public boolean messageAdded( Message message ){ return true; }
public void messageQueued( Message message ){}
public void messageRemoved( Message message ){}
public void protocolBytesSent( int byte_count ){}
public void dataBytesSent( int byte_count ){}
public void messageSent( Message message ){
if( message.equals( msg ) ) {
try{ msg_mon.enter();
sending_msgs.remove( client_msg );
}
finally{ msg_mon.exit(); }
client_msg.reportComplete();
}
}
});
out_queue.addMessage( msg, false );
|
public void | setClosingReason(java.lang.Throwable r)
closing_reason = r;
|
public void | setDebugString(java.lang.String debug) debug_string = debug;
|
public void | setMaximumMessageSize(int max_bytes)
if ( decoder != null ){
decoder.setMaximumMessageSize( max_bytes );
}
|
public void | setUserData(java.lang.Object key, java.lang.Object data)
try{
msg_mon.enter();
// assumption is write infrequently, read often -> copy-on-write
Map m = (user_data==null)?new HashMap():new HashMap( user_data );
m.put( key, data );
user_data = m;
}finally{
msg_mon.exit();
}
|
public boolean | writeMessages()Write any queued messages back to the client.
int bytes_written = out_queue.deliverToTransport( 1024*1024, false );
if( bytes_written > 0 ) last_activity_time = System.currentTimeMillis();
last_write_made_progress = bytes_written > 0;
return out_queue.getTotalSize() > 0;
|