Thousand Island v0.1.2 ThousandIsland.Handler behaviour View Source

Defines the behaviour required of the application layer of a Thousand Island server. Users pass the name of a module implementing this behaviour as the handler_module parameter when starting a server instance, and Thousand Island will call this module's handle_connection/2 function every time a client connects to the server.

Link to this section Summary

Callbacks

Called by Thousand Island once for every client connection.

Link to this section Callbacks

Link to this callback

handle_connection(arg1, term)

View Source
handle_connection(ThousandIsland.Socket.t(), term()) :: term()

Called by Thousand Island once for every client connection.

This callback is called from a private process managed by Thousand Island, and has complete and sole control over the given socket. The socket can be written to, read from, and otherwise manipulated via the ThousandIsland.Socket interface. The socket will already have completed handshaking for protocols which require such a step (such as SSL). If the socket is not closed within the callback, Thousand Island will ensure that it is properly closed.

The second argument consists of an arbitrary term specified via the handler_options parameter at server start time.

The return value of this callback is unused.