Methods Summary |
---|
public void | cancelCompatiblePeersLocation(MessageManagerListener orig_listener)
for( Iterator it = compat_checks.values().iterator(); it.hasNext(); ) {
MessageManagerListener listener = (MessageManagerListener)it.next();
if( listener == orig_listener ) {
it.remove();
break;
}
}
|
public void | deregisterMessageType(Message message)
com.aelitis.azureus.core.peermanager.messaging.MessageManager.getSingleton().deregisterMessageType( new MessageAdapter( message ) );
|
protected org.gudy.azureus2.plugins.messaging.generic.GenericMessageHandler | getHandler(java.lang.String type)
synchronized( message_handlers ){
return((GenericMessageHandler)message_handlers.get( type ));
}
|
public com.aelitis.azureus.core.nat.NATTraverser | getNATTraverser()
return( core.getNATTraverser());
|
public java.lang.String | getName()
return( "Generic Messaging" );
|
public static synchronized org.gudy.azureus2.pluginsimpl.local.messaging.MessageManagerImpl | getSingleton(com.aelitis.azureus.core.AzureusCore core)
if ( instance == null ){
instance = new MessageManagerImpl( core );
}
return instance;
|
public int | getType()
return( NATTraverser.TRAVERSE_REASON_GENERIC_MESSAGING );
|
public void | locateCompatiblePeers(org.gudy.azureus2.plugins.PluginInterface plug_interface, Message message, MessageManagerListener listener)
compat_checks.put( message, listener ); //TODO need to copy-on-write?
if( compat_checks.size() == 1 ) { //only register global peer locator listener once
plug_interface.getDownloadManager().addListener( download_manager_listener );
}
|
public java.util.Map | process(java.net.InetSocketAddress originator, java.util.Map message)
return( GenericMessageConnectionIndirect.receive( this, originator, message ));
|
public org.gudy.azureus2.plugins.messaging.generic.GenericMessageRegistration | registerGenericMessageType(java.lang.String _type, java.lang.String description, int stream_crypto, org.gudy.azureus2.plugins.messaging.generic.GenericMessageHandler handler)
final String type = "AEGEN:" + _type;
final byte[] type_bytes = type.getBytes();
final byte[][] shared_secrets = new byte[][]{ new SHA1Simple().calculateHash( type_bytes ) };
synchronized( message_handlers ){
message_handlers.put( type, handler );
}
final NetworkManager.ByteMatcher matcher =
new NetworkManager.ByteMatcher()
{
public int
matchThisSizeOrBigger()
{
return( maxSize());
}
public int
maxSize()
{
return type_bytes.length;
}
public int
minSize()
{
return maxSize();
}
public Object
matches(
TransportHelper transport, ByteBuffer to_compare, int port )
{
int old_limit = to_compare.limit();
to_compare.limit( to_compare.position() + maxSize() );
boolean matches = to_compare.equals( ByteBuffer.wrap( type_bytes ) );
to_compare.limit( old_limit ); //restore buffer structure
return matches?"":null;
}
public Object
minMatches(
TransportHelper transport, ByteBuffer to_compare, int port )
{
return( matches( transport, to_compare, port ));
}
public byte[][]
getSharedSecrets()
{
return( shared_secrets );
}
public int
getSpecificPort()
{
return( -1 );
}
};
NetworkManager.getSingleton().requestIncomingConnectionRouting(
matcher,
new NetworkManager.RoutingListener()
{
public void
connectionRouted(
final NetworkConnection connection, Object routing_data )
{
try{
ByteBuffer[] skip_buffer = { ByteBuffer.allocate(type_bytes.length) };
connection.getTransport().read( skip_buffer, 0, 1 );
if ( skip_buffer[0].remaining() != 0 ){
Debug.out( "incomplete read" );
}
GenericMessageEndpointImpl endpoint = new GenericMessageEndpointImpl( connection.getEndpoint());
GenericMessageConnectionDirect direct_connection =
GenericMessageConnectionDirect.receive(
endpoint,
type,
description,
stream_crypto,
shared_secrets );
GenericMessageConnectionImpl new_connection = new GenericMessageConnectionImpl( MessageManagerImpl.this, direct_connection );
direct_connection.connect( connection );
if ( handler.accept( new_connection )){
new_connection.accepted();
}else{
connection.close();
}
}catch( Throwable e ){
Debug.printStackTrace(e);
connection.close();
}
}
public boolean
autoCryptoFallback()
{
return( stream_crypto != MessageManager.STREAM_ENCRYPTION_RC4_REQUIRED );
}
},
new MessageStreamFactory() {
public MessageStreamEncoder createEncoder() { return new GenericMessageEncoder();}
public MessageStreamDecoder createDecoder() { return new GenericMessageDecoder(type, description);}
});
return(
new GenericMessageRegistration()
{
public GenericMessageEndpoint
createEndpoint(
InetSocketAddress notional_target )
{
return( new GenericMessageEndpointImpl( notional_target ));
}
public GenericMessageConnection
createConnection(
GenericMessageEndpoint endpoint )
throws MessageException
{
return( new GenericMessageConnectionImpl( MessageManagerImpl.this, type, description, (GenericMessageEndpointImpl)endpoint, stream_crypto, shared_secrets ));
}
public void
cancel()
{
NetworkManager.getSingleton().cancelIncomingConnectionRouting( matcher );
synchronized( message_handlers ){
message_handlers.remove( type );
}
}
});
|
public void | registerMessageType(Message message)
try {
com.aelitis.azureus.core.peermanager.messaging.MessageManager.getSingleton().registerMessageType( new MessageAdapter( message ) );
}
catch( com.aelitis.azureus.core.peermanager.messaging.MessageException me ) {
throw new MessageException( me.getMessage() );
}
|