Module datarush.commons
Interface GenericTCPServer.ConnectionHandler
- Enclosing class:
- GenericTCPServer
public static interface GenericTCPServer.ConnectionHandler
Handles incomming connections
-
Method Summary
Modifier and TypeMethodDescriptionvoiddestroy()Called upon server shutdown.voidhandle(SocketChannel connection) Handle the connection.voidinit(GenericTCPServer.ServerContext context) Called upon server start to inform the handler of context information such as the listening address.
-
Method Details
-
handle
Handle the connection. The caller handles closing the connection upon return from this method. Any errors thrown by this method will be logged by the caller. Note that this method will be called by multiple threads so implementations must be thread-safe.- Parameters:
connection- the socket connection- Throws:
Exception- if an unexpected error occurred
-
init
Called upon server start to inform the handler of context information such as the listening address. This method will be called prior to accepting any requests.- Parameters:
context- the server context
-
destroy
void destroy()Called upon server shutdown. This method will be called only after the last request has finished.
-