Interface ConnectionObserver
- All Known Implementing Classes:
NoopTransportObserver.NoopConnectionObserver
Either connectionClosed()
or connectionClosed(Throwable)
will be invoked to signal when connection
is closed. The "closed" event is considered terminal and other callbacks after that can be safely discarded because
nothing happens on the network interface after closure.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interface
An observer interface that provides visibility into read and write events related to data flow.static interface
An observer interface that provides visibility into new streams created by a multiplexed connection.static interface
An observer interface that provides visibility into proxy connect events for establishing a tunnel.static interface
An observer interface that provides visibility into read events.static interface
An observer interface that provides visibility into security handshake events.static interface
An observer interface that provides visibility into stream events.static interface
An observer interface that provides visibility into write events. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Callback when the connection is closed.void
connectionClosed
(Throwable error) Callback when the connection is closed due to anerror
.Callback when a non-multiplexed connection is established and ready.default void
connectionWritabilityChanged
(boolean isWritable) Callback when a writable state of the connection changes.Callback when a multiplexed connection is established and ready.void
onDataRead
(int size) Callback whensize
bytes are read from the connection.void
onDataWrite
(int size) Callback whensize
bytes are written to the connection.void
onFlush()
Callback when previously written data is flushed to the connection.onProxyConnect
(Object connectMsg) Callback when a proxy connect is initiated.Deprecated.onSecurityHandshake
(SslConfig sslConfig) Callback when a security handshake is initiated.default void
Deprecated.default void
Callback when a transport handshake completes.
-
Method Details
-
onDataRead
void onDataRead(int size) Callback whensize
bytes are read from the connection.- Parameters:
size
- size of the data chunk read
-
onDataWrite
void onDataWrite(int size) Callback whensize
bytes are written to the connection.- Parameters:
size
- size of the data chunk written
-
onFlush
void onFlush()Callback when previously written data is flushed to the connection. -
onTransportHandshakeComplete
Deprecated.Callback when a transport handshake completes.Transport protocols that require a handshake in order to connect. Example: TCP "three-way handshake".
-
onTransportHandshakeComplete
Callback when a transport handshake completes.Transport protocols that require a handshake in order to connect. Example: TCP "three-way handshake".
- Parameters:
info
-ConnectionInfo
for the connection after transport handshake completes. Note that theConnectionInfo.sslSession()
will always returnnull
since it is called before theonSecurityHandshake(SslConfig)
security handshake} is performed (and as a result no SSL session has been established). Also,ConnectionInfo.protocol()
will return L4 (transport) protocol. FinalizedConnectionInfo
will be available viaconnectionEstablished(ConnectionInfo)
ormultiplexedConnectionEstablished(ConnectionInfo)
callbacks.
-
onProxyConnect
Callback when a proxy connect is initiated.For a typical connection, this callback is invoked after
onTransportHandshakeComplete(ConnectionInfo)
.- Parameters:
connectMsg
- a message sent to a proxy in request to establish a connection to the target server- Returns:
- a new
ConnectionObserver.ProxyConnectObserver
that provides visibility into proxy connect events.
-
onSecurityHandshake
Deprecated.Callback when a security handshake is initiated.For a typical connection, this callback is invoked after
onTransportHandshakeComplete(ConnectionInfo)
. There are exceptions:- For a TCP connection, when
ServiceTalkSocketOptions.TCP_FASTOPEN_CONNECT
option is configured and the Fast Open feature is supported by the OS, this callback may be invoked earlier. Note, even if the Fast Open is available and configured, it may not actually happen if the Fast Open Cookie isnull
or rejected by the server. - For a proxy connections, the handshake may happen after an observer returned by
onProxyConnect(Object)
completes successfully.
- Returns:
- a new
ConnectionObserver.SecurityHandshakeObserver
that provides visibility into security handshake events - See Also:
- For a TCP connection, when
-
onSecurityHandshake
Callback when a security handshake is initiated.For a typical connection, this callback is invoked after
onTransportHandshakeComplete(ConnectionInfo)
. There are exceptions:- For a TCP connection, when
ServiceTalkSocketOptions.TCP_FASTOPEN_CONNECT
option is configured and the Fast Open feature is supported by the OS, this callback may be invoked earlier. Note, even if the Fast Open is available and configured, it may not actually happen if the Fast Open Cookie isnull
or rejected by the server. - For a proxy connections, the handshake may happen after an observer returned by
onProxyConnect(Object)
completes successfully.
- Parameters:
sslConfig
- theSslConfig
used when performing the security handshake.- Returns:
- a new
ConnectionObserver.SecurityHandshakeObserver
that provides visibility into security handshake events - See Also:
- For a TCP connection, when
-
connectionEstablished
Callback when a non-multiplexed connection is established and ready.- Parameters:
info
-ConnectionInfo
for the established connection- Returns:
- a new
ConnectionObserver.DataObserver
that provides visibility into read and write events
-
multiplexedConnectionEstablished
Callback when a multiplexed connection is established and ready.- Parameters:
info
-ConnectionInfo
for the established connection- Returns:
- a new
ConnectionObserver.MultiplexedObserver
that provides visibility into new streams
-
connectionWritabilityChanged
default void connectionWritabilityChanged(boolean isWritable) Callback when a writable state of the connection changes.- Parameters:
isWritable
- describes the current state of the connection:true
when the I/O thread will perform the requested write operation immediately. Iffalse
, write requests will be queued until the I/O thread is ready to process the queued items and the transport will start applying backpressure.
-
connectionClosed
Callback when the connection is closed due to anerror
.- Parameters:
error
- an occurred error
-
connectionClosed
void connectionClosed()Callback when the connection is closed.
-
onSecurityHandshake(SslConfig)