Interface Connection
-
- All Superinterfaces:
java.lang.AutoCloseable
,java.io.Closeable
- All Known Implementing Classes:
AbstractConnection
,AbstractWebSocketConnection
,ALPNClientConnection
,ALPNServerConnection
,ConnectHandler.DownstreamConnection
,ConnectHandler.UpstreamConnection
,HTTP2Connection
,HTTP2ServerConnection
,HttpConnection
,HttpConnectionOverFCGI
,HttpConnectionOverHTTP
,NegotiatingClientConnection
,NegotiatingServerConnection
,ProxyConnection
,ProxyProtocolClientConnectionFactory.ProxyProtocolConnection
,ServerFCGIConnection
,SslConnection
,WebSocketClientConnection
,WebSocketServerConnection
public interface Connection extends java.io.Closeable
A
Connection
is associated to anEndPoint
so that I/O events happening on theEndPoint
can be processed by theConnection
.A typical implementation of
Connection
overridesonOpen()
toset read interest
on theEndPoint
, and when theEndPoint
signals read readyness, thisConnection
can read bytes from the network and interpret them.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
Connection.Listener
A Listener for connection events.static interface
Connection.UpgradeFrom
Connection
implementations implement this interface when they can upgrade from the protocol they speak (for example HTTP/1.1) to a different protocol (e.g.static interface
Connection.UpgradeTo
Connection
implementations implement this interface when they can be upgraded to the protocol they speak (e.g.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
addListener(Connection.Listener listener)
Adds a listener of connection events.void
close()
Performs a logical close of this connection.long
getBytesIn()
long
getBytesOut()
long
getCreatedTimeStamp()
EndPoint
getEndPoint()
long
getMessagesIn()
long
getMessagesOut()
void
onClose()
Callback method invoked when this connection is closed.boolean
onIdleExpired()
Callback method invoked upon an idle timeout event.void
onOpen()
Callback method invoked when this connection is opened.void
removeListener(Connection.Listener listener)
Removes a listener of connection events.
-
-
-
Method Detail
-
addListener
void addListener(Connection.Listener listener)
Adds a listener of connection events.
- Parameters:
listener
- the listener to add
-
removeListener
void removeListener(Connection.Listener listener)
Removes a listener of connection events.
- Parameters:
listener
- the listener to remove
-
onOpen
void onOpen()
Callback method invoked when this connection is opened.
Creators of the connection implementation are responsible for calling this method.
-
onClose
void onClose()
Callback method invoked when this connection is closed.
Creators of the connection implementation are responsible for calling this method.
-
close
void close()
Performs a logical close of this connection.
For simple connections, this may just mean to delegate the close to the associated
EndPoint
but, for example, SSL connections should write the SSL close message before closing the associatedEndPoint
.- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
-
onIdleExpired
boolean onIdleExpired()
Callback method invoked upon an idle timeout event.
Implementations of this method may return true to indicate that the idle timeout handling should proceed normally, typically failing the EndPoint and causing it to be closed.
When false is returned, the handling of the idle timeout event is halted immediately and the EndPoint left in the state it was before the idle timeout event.
- Returns:
- true to let the EndPoint handle the idle timeout, false to tell the EndPoint to halt the handling of the idle timeout.
-
getMessagesIn
long getMessagesIn()
-
getMessagesOut
long getMessagesOut()
-
getBytesIn
long getBytesIn()
-
getBytesOut
long getBytesOut()
-
getCreatedTimeStamp
long getCreatedTimeStamp()
-
-