Sovite.Listener.Handler behaviour (sovite v0.2.0)

Copy Markdown View Source

Behaviour for the process that serves one accepted connection.

The listener starts it with start_link/2 under its connection supervisor, then hands over the socket. The process must call Sovite.Listener.handshake/1 before using the socket.

Summary

Callbacks

Called in the acceptor when a connection is refused because of a limit, before the socket is closed. Use it to send a protocol-level refusal, such as SMTP 421. It must not block for long.

Starts the connection process. opts is the listener's :handler_opts.

Callbacks

reject(socket, reject_reason, opts)

(optional)
@callback reject(:gen_tcp.socket(), Sovite.Listener.reject_reason(), opts :: term()) ::
  any()

Called in the acceptor when a connection is refused because of a limit, before the socket is closed. Use it to send a protocol-level refusal, such as SMTP 421. It must not block for long.

start_link(connection_info, opts)

@callback start_link(Sovite.Listener.connection_info(), opts :: term()) ::
  GenServer.on_start()

Starts the connection process. opts is the listener's :handler_opts.