z_mqtt_sessions_runtime (zotonic_core v1.0.0-rc.17)

Zotonic specific callbacks for MQTT connections

Summary

Functions

If the connection is authenticated, then the connection user MUST be the session user.

Re-authentication. This is called when the client requests a re-authentication (or replies in a AUTH re-authentication).

Return the MQTT pool name for the given hostname.

Functions

connect(Packet, IsSessionPresent, Options, Context)

control_message(SubTopic, Message, Context)

-spec control_message(SubTopic, Message, Context) -> {ok, Context1}
                         when
                             SubTopic :: [binary()],
                             Message :: mqtt_packet_map:mqtt_packet(),
                             Context :: z:context(),
                             Context1 :: z:context().

is_allowed(Action, Topic, Packet, Context)

-spec is_allowed(publish | subscribe,
                 mqtt_sessions_runtime:topic(),
                 mqtt_packet_map:mqtt_packet(),
                 z:context()) ->
                    boolean().

is_valid_message(Msg, Options, Context)

If the connection is authenticated, then the connection user MUST be the session user.

new_user_context(Site, ClientId, SessionOptions)

-spec new_user_context(Site, ClientId, SessionOptions) -> Context
                          when
                              Site :: atom(),
                              ClientId :: binary(),
                              SessionOptions :: mqtt_sessions:session_options(),
                              Context :: z:context().

ping(Context)

-spec ping(Context) -> {ok, Context1} when Context :: z:context(), Context1 :: z:context().

pool_default()

-spec pool_default() -> {error, unknown_host}.

reauth(_, Context)

-spec reauth(mqtt_packet_map:mqtt_packet(), z:context()) ->
                {ok, mqtt_packet_map:mqtt_packet(), z:context()} | {error, term()}.

Re-authentication. This is called when the client requests a re-authentication (or replies in a AUTH re-authentication).

vhost_pool(Hostname)

-spec vhost_pool(binary()) -> {ok, atom()} | {error, unknown_host}.

Return the MQTT pool name for the given hostname.