com.aelitis.azureus.core.networkmanager.impl
Class NetworkConnectionImpl

java.lang.Object
  extended by com.aelitis.azureus.core.networkmanager.NetworkConnectionHelper
      extended by com.aelitis.azureus.core.networkmanager.impl.NetworkConnectionImpl
All Implemented Interfaces:
NetworkConnection, NetworkConnectionBase

public class NetworkConnectionImpl
extends NetworkConnectionHelper
implements NetworkConnection


Nested Class Summary
protected static class NetworkConnectionImpl.bogusTransport
           
 
Nested classes/interfaces inherited from interface com.aelitis.azureus.core.networkmanager.NetworkConnection
NetworkConnection.ConnectionListener
 
Constructor Summary
NetworkConnectionImpl(ConnectionEndpoint _target, MessageStreamEncoder encoder, MessageStreamDecoder decoder, boolean _connect_with_crypto, boolean _allow_fallback, byte[][] _shared_secrets)
          Constructor for new OUTbound connection.
NetworkConnectionImpl(Transport _transport, MessageStreamEncoder encoder, MessageStreamDecoder decoder)
          Constructor for new INbound connection.
 
Method Summary
 void close(java.lang.String reason)
          Close and shutdown this connection.
 void connect(java.nio.ByteBuffer initial_outbound_data, int priority, NetworkConnection.ConnectionListener listener)
           
 void connect(int priority, NetworkConnection.ConnectionListener listener)
          Connect this connection's transport, i.e.
 Transport detachTransport()
          Decouples the transport from this network connection so it can be reused
 void enableEnhancedMessageProcessing(boolean enable, int partition_id)
          Upgrade the connection to high-speed transfer processing.
 ConnectionEndpoint getEndpoint()
           
 IncomingMessageQueue getIncomingMessageQueue()
          Get the connection's incoming message queue.
 int getMssSize()
           
 OutgoingMessageQueue getOutgoingMessageQueue()
          Get the connection's outgoing message queue.
 java.lang.String getString()
           
 Transport getTransport()
          Get the connection's data transport interface.
 TransportBase getTransportBase()
          Get the connection's data transport interface.
 java.lang.Object getUserData(java.lang.Object key)
           
 boolean isConnected()
           
 boolean isIncoming()
           
 boolean isLANLocal()
          Is the connection within the local LAN network.
 void notifyOfException(java.lang.Throwable error)
          Inform connection of a thrown exception.
 java.lang.Object setUserData(java.lang.Object key, java.lang.Object value)
           
 void startMessageProcessing()
          Begin processing incoming and outgoing message queues.
 java.lang.String toString()
           
 
Methods inherited from class com.aelitis.azureus.core.networkmanager.NetworkConnectionHelper
addRateLimiter, getDownloadLimit, getRateLimiters, getUploadLimit, removeRateLimiter, setDownloadLimit, setUploadLimit
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.aelitis.azureus.core.networkmanager.NetworkConnectionBase
addRateLimiter, getDownloadLimit, getRateLimiters, getUploadLimit, removeRateLimiter, setDownloadLimit, setUploadLimit
 

Constructor Detail

NetworkConnectionImpl

public NetworkConnectionImpl(ConnectionEndpoint _target,
                             MessageStreamEncoder encoder,
                             MessageStreamDecoder decoder,
                             boolean _connect_with_crypto,
                             boolean _allow_fallback,
                             byte[][] _shared_secrets)
Constructor for new OUTbound connection. The connection is not yet established upon instantiation; use connect() to do so.

Parameters:
_remote_address - to connect to
encoder - default message stream encoder to use for the outgoing queue
decoder - default message stream decoder to use for the incoming queue

NetworkConnectionImpl

public NetworkConnectionImpl(Transport _transport,
                             MessageStreamEncoder encoder,
                             MessageStreamDecoder decoder)
Constructor for new INbound connection. The connection is assumed to be already established, by the given already-connected channel.

Parameters:
_remote_channel - connected by
data_already_read - bytestream already read during routing
encoder - default message stream encoder to use for the outgoing queue
decoder - default message stream decoder to use for the incoming queue
Method Detail

getEndpoint

public ConnectionEndpoint getEndpoint()
Specified by:
getEndpoint in interface NetworkConnectionBase

isIncoming

public boolean isIncoming()
Specified by:
isIncoming in interface NetworkConnectionBase

connect

public void connect(int priority,
                    NetworkConnection.ConnectionListener listener)
Description copied from interface: NetworkConnection
Connect this connection's transport, i.e. establish the network connection. If this connection is already established (from an incoming connection for example), then this provides a mechanism to register the connection listener, in which case connectSuccess() will be called immediately.

Specified by:
connect in interface NetworkConnection
listener - notified on connect success or failure

connect

public void connect(java.nio.ByteBuffer initial_outbound_data,
                    int priority,
                    NetworkConnection.ConnectionListener listener)
Specified by:
connect in interface NetworkConnection

detachTransport

public Transport detachTransport()
Description copied from interface: NetworkConnection
Decouples the transport from this network connection so it can be reused

Specified by:
detachTransport in interface NetworkConnection
Returns:
null if detach failed

close

public void close(java.lang.String reason)
Description copied from interface: NetworkConnection
Close and shutdown this connection.

Specified by:
close in interface NetworkConnection

notifyOfException

public void notifyOfException(java.lang.Throwable error)
Description copied from interface: NetworkConnectionBase
Inform connection of a thrown exception.

Specified by:
notifyOfException in interface NetworkConnectionBase
Parameters:
error - exception

getOutgoingMessageQueue

public OutgoingMessageQueue getOutgoingMessageQueue()
Description copied from interface: NetworkConnectionBase
Get the connection's outgoing message queue.

Specified by:
getOutgoingMessageQueue in interface NetworkConnectionBase
Returns:
outbound message queue

getIncomingMessageQueue

public IncomingMessageQueue getIncomingMessageQueue()
Description copied from interface: NetworkConnectionBase
Get the connection's incoming message queue.

Specified by:
getIncomingMessageQueue in interface NetworkConnectionBase
Returns:
inbound message queue

startMessageProcessing

public void startMessageProcessing()
Description copied from interface: NetworkConnection
Begin processing incoming and outgoing message queues.

Specified by:
startMessageProcessing in interface NetworkConnection

enableEnhancedMessageProcessing

public void enableEnhancedMessageProcessing(boolean enable,
                                            int partition_id)
Description copied from interface: NetworkConnection
Upgrade the connection to high-speed transfer processing.

Specified by:
enableEnhancedMessageProcessing in interface NetworkConnection
Parameters:
enable - true for high-speed processing, false for normal processing

getTransport

public Transport getTransport()
Description copied from interface: NetworkConnection
Get the connection's data transport interface.

Specified by:
getTransport in interface NetworkConnection
Returns:
the transport - MAY BE NULL if not yet fully connected

getTransportBase

public TransportBase getTransportBase()
Description copied from interface: NetworkConnectionBase
Get the connection's data transport interface.

Specified by:
getTransportBase in interface NetworkConnectionBase
Returns:
the transport - MAY BE NULL if not yet fully connected

getMssSize

public int getMssSize()
Specified by:
getMssSize in interface NetworkConnectionBase

setUserData

public java.lang.Object setUserData(java.lang.Object key,
                                    java.lang.Object value)
Specified by:
setUserData in interface NetworkConnection

getUserData

public java.lang.Object getUserData(java.lang.Object key)
Specified by:
getUserData in interface NetworkConnection

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

isConnected

public boolean isConnected()
Specified by:
isConnected in interface NetworkConnection

isLANLocal

public boolean isLANLocal()
Description copied from interface: NetworkConnectionBase
Is the connection within the local LAN network.

Specified by:
isLANLocal in interface NetworkConnectionBase
Returns:
true if within LAN, false of outside the LAN segment

getString

public java.lang.String getString()
Specified by:
getString in interface NetworkConnectionBase