Ircxd.Client.Adapter behaviour (ircxd v1.1.0)

Copy Markdown View Source

Application integration contract for an Ircxd.Client process.

A client adapter receives normalized client events and owns any application state derived from them. It is configured with the client's :adapter option as {module, init_arg}.

Summary

Types

Connection data for one event.

A legacy event or an event envelope.

Application state for one client process.

Callbacks

Handles one client event and returns the next adapter state.

Initializes the adapter state from the configured argument.

Types

context()

@type context() :: %{
  client: pid(),
  host: String.t(),
  port: :inet.port_number(),
  tls?: boolean(),
  nick: String.t() | nil,
  client_info: Ircxd.Client.Info.t()
}

Connection data for one event.

event()

A legacy event or an event envelope.

state()

@type state() :: term()

Application state for one client process.

Callbacks

handle_event(event, context, state)

@callback handle_event(event(), context(), state()) :: {:ok, state()}

Handles one client event and returns the next adapter state.

init(term)

@callback init(term()) :: {:ok, state()} | {:error, term()}

Initializes the adapter state from the configured argument.