Class NetworkConnectionImpl
java.lang.Object
com.biglybt.core.networkmanager.NetworkConnectionHelper
com.biglybt.core.networkmanager.impl.NetworkConnectionImpl
- All Implemented Interfaces:
ControllerAllocationManagement, NetworkConnection, NetworkConnectionBase
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from interface NetworkConnection
NetworkConnection.ConnectionListener -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate booleanprivate booleanprivate booleanprivate ConnectionAttemptprivate final ConnectionEndpointprivate intprivate final IncomingMessageQueueImplprivate booleanprivate final booleanprivate byteprivate final OutgoingMessageQueueImplprivate byte[][]private booleanprivate TransportFields inherited from interface ControllerAllocationManagement
UNALLOCATED_PARTITION -
Constructor Summary
ConstructorsConstructorDescriptionNetworkConnectionImpl(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
Modifier and TypeMethodDescriptionvoidClose and shutdown this connection.voidconnect(int priority, NetworkConnection.ConnectionListener listener) Connect this connection's transport, i.e.voidconnect(ByteBuffer initial_outbound_data, int priority, NetworkConnection.ConnectionListener listener) Decouples the transport from this network connection so it can be reusedvoidenableEnhancedMessageProcessing(boolean enable, int partition_id) Upgrade the connection to high-speed transfer processing.Get the connection's incoming message queue.intGet the connection's outgoing message queue.Get the connection's data transport interface.Get the connection's data transport interface.getUserData(Object key) booleanisClosed()booleanbooleanbooleanIs the connection within the local LAN network.voidnotifyOfException(Throwable error) Inform connection of a thrown exception.voidsetUserData(Object key, Object value) voidBegin processing incoming and outgoing message queues.toString()Methods inherited from class NetworkConnectionHelper
activeReadControllerRelease, activeWriteControllerRelease, addRateLimiter, getDownloadLimit, getPartitionID, getRateLimiters, getUploadLimit, isReadControllerActive, isWriteControllerActive, removeRateLimiter, setDownloadLimit, setReadControllerInactive, setTargetReadControllerPartition, setTargetWriteControllerPartition, setUploadLimit, setWriteControllerInactiveMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface ControllerAllocationManagement
activeReadControllerRelease, activeWriteControllerRelease, isReadControllerActive, isWriteControllerActive, setReadControllerInactive, setTargetReadControllerPartition, setTargetWriteControllerPartition, setWriteControllerInactiveMethods inherited from interface NetworkConnectionBase
addRateLimiter, getDownloadLimit, getPartitionID, getRateLimiters, getUploadLimit, removeRateLimiter, setDownloadLimit, setUploadLimit
-
Field Details
-
connection_endpoint
-
is_incoming
private final boolean is_incoming -
connect_with_crypto
private boolean connect_with_crypto -
allow_fallback
private boolean allow_fallback -
connection_listener
-
is_connected
private boolean is_connected -
is_lan_local
private byte is_lan_local -
enhanced_partition_id
private int enhanced_partition_id -
outgoing_message_queue
-
incoming_message_queue
-
transport
-
connection_attempt
-
started
private boolean started -
closed
private volatile boolean closed -
user_data
-
-
Constructor Details
-
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:
encoder- default message stream encoder to use for the outgoing queuedecoder- default message stream decoder to use for the incoming queue_remote_address- to connect to
-
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:
encoder- default message stream encoder to use for the outgoing queuedecoder- default message stream decoder to use for the incoming queue_remote_channel- connected bydata_already_read- bytestream already read during routing
-
-
Method Details
-
getEndpoint
- Specified by:
getEndpointin interfaceNetworkConnectionBase
-
isIncoming
public boolean isIncoming()- Specified by:
isIncomingin interfaceNetworkConnectionBase
-
connect
Description copied from interface:NetworkConnectionConnect 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:
connectin interfaceNetworkConnection- Parameters:
listener- notified on connect success or failure
-
connect
public void connect(ByteBuffer initial_outbound_data, int priority, NetworkConnection.ConnectionListener listener) - Specified by:
connectin interfaceNetworkConnection
-
detachTransport
Description copied from interface:NetworkConnectionDecouples the transport from this network connection so it can be reused- Specified by:
detachTransportin interfaceNetworkConnection- Returns:
- null if detach failed
-
close
Description copied from interface:NetworkConnectionClose and shutdown this connection.- Specified by:
closein interfaceNetworkConnection- Specified by:
closein classNetworkConnectionHelper
-
isClosed
public boolean isClosed()- Specified by:
isClosedin interfaceNetworkConnectionBase
-
notifyOfException
Description copied from interface:NetworkConnectionBaseInform connection of a thrown exception.- Specified by:
notifyOfExceptionin interfaceNetworkConnectionBase- Parameters:
error- exception
-
getOutgoingMessageQueue
Description copied from interface:NetworkConnectionBaseGet the connection's outgoing message queue.- Specified by:
getOutgoingMessageQueuein interfaceNetworkConnectionBase- Returns:
- outbound message queue
-
getIncomingMessageQueue
Description copied from interface:NetworkConnectionBaseGet the connection's incoming message queue.- Specified by:
getIncomingMessageQueuein interfaceNetworkConnectionBase- Returns:
- inbound message queue
-
startMessageProcessing
public void startMessageProcessing()Description copied from interface:NetworkConnectionBegin processing incoming and outgoing message queues.- Specified by:
startMessageProcessingin interfaceNetworkConnection
-
enableEnhancedMessageProcessing
public void enableEnhancedMessageProcessing(boolean enable, int partition_id) Description copied from interface:NetworkConnectionUpgrade the connection to high-speed transfer processing.- Specified by:
enableEnhancedMessageProcessingin interfaceNetworkConnection- Parameters:
enable- true for high-speed processing, false for normal processing
-
getTransport
Description copied from interface:NetworkConnectionGet the connection's data transport interface.- Specified by:
getTransportin interfaceNetworkConnection- Returns:
- the transport - MAY BE NULL if not yet fully connected
-
getTransportBase
Description copied from interface:NetworkConnectionBaseGet the connection's data transport interface.- Specified by:
getTransportBasein interfaceNetworkConnectionBase- Returns:
- the transport - MAY BE NULL if not yet fully connected
-
getMssSize
public int getMssSize()- Specified by:
getMssSizein interfaceNetworkConnectionBase
-
setUserData
- Specified by:
setUserDatain interfaceNetworkConnection
-
getUserData
- Specified by:
getUserDatain interfaceNetworkConnection
-
toString
-
isConnected
public boolean isConnected()- Specified by:
isConnectedin interfaceNetworkConnection
-
isLANLocal
public boolean isLANLocal()Description copied from interface:NetworkConnectionBaseIs the connection within the local LAN network.- Specified by:
isLANLocalin interfaceNetworkConnectionBase- Returns:
- true if within LAN, false of outside the LAN segment
-
resetLANLocalStatus
public void resetLANLocalStatus()- Specified by:
resetLANLocalStatusin interfaceNetworkConnectionBase
-
getString
- Specified by:
getStringin interfaceNetworkConnectionBase
-