MQTT v0.2.0 MQTT.Server behaviour

A behaviour module for implementing an MQTT “broker”.

Summary

Types

The init parameters, received from the newly connected client

The reason for rejecting a connection

Functions

See :mqtt_server.enter_loop/3

See :mqtt_server.stop/1

See :mqtt_server.stop/3

Types

action()
action ::
  {:publish, topic :: String.t, message :: iodata} |
  {:publish, topic :: String.t, message :: iodata, %{optional(:qos) => :mqtt_packet.qos, optional(:retain) => boolean}} |
  {:reply, :gen_statem.from, term}
init_parameters()
init_parameters() :: %{:protocol => String.t, :clean_session => boolean, :client_id => String.t, optional(:username) => String.t, optional(:password) => String.t, optional(:last_will) => %{topic: iodata, message: iodata, qos: :mqtt_packet.qos, retain: boolean}}

The init parameters, received from the newly connected client

init_stop_reason()
init_stop_reason ::
  :identifier_rejected |
  :server_unavailable |
  :bad_username_or_password |
  :not_authorized |
  6..255

The reason for rejecting a connection

Functions

enter_loop(module, args, transport)

See :mqtt_server.enter_loop/3.

stop(pid)

See :mqtt_server.stop/1.

stop(pid, reason, timeout)

See :mqtt_server.stop/3.

Callbacks

code_change(old_vsn, state, extra)
code_change(old_vsn, state :: any, extra :: term) ::
  {:ok, new_state :: any} |
  {:error, reason :: term} when old_vsn: term | {:down, term}
handle_call(call, from, state)
handle_call(call :: any, from :: :gen_statem.from, state) ::
  {:ok, state} |
  {:ok, state, action | [action]} |
  {:stop, reason :: term} when state: any
handle_cast(cast, state)
handle_cast(cast :: any, state) ::
  {:ok, state} |
  {:ok, state, action | [action]} |
  {:stop, reason :: term} when state: any
handle_info(info, state)
handle_info(info :: any, state) ::
  {:ok, state} |
  {:ok, state, action | [action]} |
  {:stop, reason :: term} when state: any
handle_publish(topic, message, opts, state)
handle_publish(topic :: String.t, message :: binary, opts :: map, state) ::
  {:ok, state} |
  {:ok, state, action | [action]} |
  {:stop, reason :: term} when state: any
handle_subscribe(topic, qos, state)
handle_subscribe(topic :: String.t, qos :: :mqtt_packet.qos, state) ::
  {:ok, :mqtt_packet.qos | :failed, state} |
  {:ok, :mqtt_packet.qos | :failed, state, action | [action]} |
  {:stop, reason :: term} when state: any
handle_unsubscribe(topic, state)
handle_unsubscribe(topic :: binary, state) ::
  {:ok, state} |
  {:ok, state, action | [action]} |
  {:stop, reason :: term} when state: any
init(args, params)
init(args :: any, params :: init_parameters) ::
  {:ok, state} |
  {:stop, reason :: init_stop_reason} when state: any
terminate(arg0, state)
terminate(:normal | :shutdown | {:shutdown, term} | term, state) :: any when state: any