Class NetworkConnectionImpl
java.lang.Object
com.biglybt.core.networkmanager.NetworkConnectionHelper
com.biglybt.core.networkmanager.impl.NetworkConnectionImpl
- All Implemented Interfaces:
NetworkConnection
,NetworkConnectionBase
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from interface com.biglybt.core.networkmanager.NetworkConnection
NetworkConnection.ConnectionListener
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate boolean
private boolean
private boolean
private ConnectionAttempt
private final ConnectionEndpoint
private int
private final IncomingMessageQueueImpl
private boolean
private final boolean
private byte
private final OutgoingMessageQueueImpl
private byte[][]
private boolean
private Transport
-
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 TypeMethodDescriptionvoid
Close and shutdown this connection.void
connect
(int priority, NetworkConnection.ConnectionListener listener) Connect this connection's transport, i.e.void
connect
(ByteBuffer initial_outbound_data, int priority, NetworkConnection.ConnectionListener listener) Decouples the transport from this network connection so it can be reusedvoid
enableEnhancedMessageProcessing
(boolean enable, int partition_id) Upgrade the connection to high-speed transfer processing.Get the connection's incoming message queue.int
Get the connection's outgoing message queue.Get the connection's data transport interface.Get the connection's data transport interface.getUserData
(Object key) boolean
isClosed()
boolean
boolean
boolean
Is the connection within the local LAN network.void
notifyOfException
(Throwable error) Inform connection of a thrown exception.void
setUserData
(Object key, Object value) void
Begin processing incoming and outgoing message queues.toString()
Methods inherited from class com.biglybt.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.biglybt.core.networkmanager.NetworkConnectionBase
addRateLimiter, getDownloadLimit, 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:
_remote_address
- to connect toencoder
- default message stream encoder to use for the outgoing queuedecoder
- 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 bydata_already_read
- bytestream already read during routingencoder
- default message stream encoder to use for the outgoing queuedecoder
- default message stream decoder to use for the incoming queue
-
-
Method Details
-
getEndpoint
- Specified by:
getEndpoint
in interfaceNetworkConnectionBase
-
isIncoming
public boolean isIncoming()- Specified by:
isIncoming
in interfaceNetworkConnectionBase
-
connect
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 interfaceNetworkConnection
listener
- notified on connect success or failure
-
connect
public void connect(ByteBuffer initial_outbound_data, int priority, NetworkConnection.ConnectionListener listener) - Specified by:
connect
in interfaceNetworkConnection
-
detachTransport
Description copied from interface:NetworkConnection
Decouples the transport from this network connection so it can be reused- Specified by:
detachTransport
in interfaceNetworkConnection
- Returns:
- null if detach failed
-
close
Description copied from interface:NetworkConnection
Close and shutdown this connection.- Specified by:
close
in interfaceNetworkConnection
-
isClosed
public boolean isClosed()- Specified by:
isClosed
in interfaceNetworkConnectionBase
-
notifyOfException
Description copied from interface:NetworkConnectionBase
Inform connection of a thrown exception.- Specified by:
notifyOfException
in interfaceNetworkConnectionBase
- Parameters:
error
- exception
-
getOutgoingMessageQueue
Description copied from interface:NetworkConnectionBase
Get the connection's outgoing message queue.- Specified by:
getOutgoingMessageQueue
in interfaceNetworkConnectionBase
- Returns:
- outbound message queue
-
getIncomingMessageQueue
Description copied from interface:NetworkConnectionBase
Get the connection's incoming message queue.- Specified by:
getIncomingMessageQueue
in interfaceNetworkConnectionBase
- Returns:
- inbound message queue
-
startMessageProcessing
public void startMessageProcessing()Description copied from interface:NetworkConnection
Begin processing incoming and outgoing message queues.- Specified by:
startMessageProcessing
in interfaceNetworkConnection
-
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 interfaceNetworkConnection
- Parameters:
enable
- true for high-speed processing, false for normal processing
-
getTransport
Description copied from interface:NetworkConnection
Get the connection's data transport interface.- Specified by:
getTransport
in interfaceNetworkConnection
- Returns:
- the transport - MAY BE NULL if not yet fully connected
-
getTransportBase
Description copied from interface:NetworkConnectionBase
Get the connection's data transport interface.- Specified by:
getTransportBase
in interfaceNetworkConnectionBase
- Returns:
- the transport - MAY BE NULL if not yet fully connected
-
getMssSize
public int getMssSize()- Specified by:
getMssSize
in interfaceNetworkConnectionBase
-
setUserData
- Specified by:
setUserData
in interfaceNetworkConnection
-
getUserData
- Specified by:
getUserData
in interfaceNetworkConnection
-
toString
-
isConnected
public boolean isConnected()- Specified by:
isConnected
in interfaceNetworkConnection
-
isLANLocal
public boolean isLANLocal()Description copied from interface:NetworkConnectionBase
Is the connection within the local LAN network.- Specified by:
isLANLocal
in interfaceNetworkConnectionBase
- Returns:
- true if within LAN, false of outside the LAN segment
-
resetLANLocalStatus
public void resetLANLocalStatus()- Specified by:
resetLANLocalStatus
in interfaceNetworkConnectionBase
-
getString
- Specified by:
getString
in interfaceNetworkConnectionBase
-