z_mqtt (zotonic_core v1.0.0-rc.17)
Interface to MQTT pubsub functionality
Summary
Functions
Check if the MQTT client for this request context is alive.
Map subscription topic to a topic filter.
Ensure that the topic is prefixed with "bridge/origin/".
Find the Pid of the MQTT client process for this request context.
Types
-type publish_options() :: #{retain => boolean(), qos => 0 | 1 | 2}.
-type topic() :: mqtt_sessions:topic().
-type topic_any() :: mqtt_sessions:topic() | m_rsc:resource_id() | {object, list()} | {subject, list()}.
Functions
-spec await_response(mqtt_sessions:topic(), z:context()) -> {ok, mqtt_packet_map:mqtt_packet()} | {error, timeout}.
-spec await_response(mqtt_sessions:topic(), pos_integer(), z:context()) -> {ok, mqtt_packet_map:mqtt_packet()} | {error, timeout}.
-spec call(mqtt_packet_map:mqtt_packet(), z:context()) -> {ok, term()} | {error, term()}.
Check if the MQTT client for this request context is alive.
-spec map_topic(Topic, Context) -> {ok, mqtt_sessions:topic()} | {error, no_client | term()} when Topic :: mqtt_sessions:topic() | undefined | atom() | m_rsc:resource_id(), Context :: z:context().
-spec map_topic_filter(TopicAny, Context) -> {ok, topic()} | {error, no_topic | term()} when TopicAny :: topic_any() | undefined, Context :: z:context().
Map subscription topic to a topic filter.
-spec origin_topic(Topic) -> OriginTopic when Topic :: mqtt_sessions:topic(), OriginTopic :: mqtt_sessions:topic().
Ensure that the topic is prefixed with "bridge/origin/".
-spec publish(mqtt_packet_map:mqtt_packet(), z:context()) -> ok | {error, term()}.
-spec publish(topic(), term(), publish_options(), z:context()) -> ok | {error, term()}.
-spec temp_response_topic(z:context()) -> {ok, mqtt_sessions:topic()} | {error, term()}.
Find the Pid of the MQTT client process for this request context.