View Source mqtt_sessions (mqtt_sessions v2.2.0)
Link to this section Summary
Functions
Stream the connect message - connect a MQTT session or return an error
Stream the connect message - connect a MQTT session or return an error
Handle incoming data for session. Call this after a successful connect. The session will disconnect on an illegal packet.
Return the runtime module for AUTH and other callbacks.
Set the runtime module
Limit the number of sidejobs for message dispatching.
Link to this section Types
-type callback() :: pid() | {module(), atom(), list()}.
-type mqtt_msg() :: mqtt_sessions_router:mqtt_msg().
-type msg_options() ::
#{transport => pid() | function(),
peer_ip => tuple() | undefined,
context_prefs => map(),
connection_pid => pid()}.
-type session_options() ::
#{routing_id => binary(), peer_ip => tuple() | undefined, context_prefs => map()}.
-type session_ref() :: pid() | binary().
-type subscriber() :: mqtt_sessions_router:subscriber().
-type subscriber_options() :: mqtt_sessions_router:subscriber_options().
-type topic() :: mqtt_packet_map:mqtt_topic().
Link to this section Functions
-spec await_response(topic()) -> {ok, mqtt_packet_map:mqtt_packet()} | {error, timeout}.
-spec await_response(topic(), pos_integer()) -> {ok, mqtt_packet_map:mqtt_packet()} | {error, timeout}; (atom(), topic()) -> {ok, mqtt_packet_map:mqtt_packet()} | {error, timeout}.
-spec fetch_queue(session_ref()) -> {ok, [mqtt_packet_map:mqtt_packet() | binary()]} | {error, notfound}.
-spec fetch_queue(atom(), session_ref()) -> {ok, [mqtt_packet_map:mqtt_packet() | binary()]} | {error, notfound}.
-spec find_session(session_ref()) -> {ok, pid()} | {error, notfound}.
-spec find_session(atom(), session_ref()) -> {ok, pid()} | {error, notfound}.
-spec get_transport(pid()) -> {ok, pid()} | {error, notransport | noproc}.
-spec get_user_context(session_ref()) -> {ok, term()} | {error, notfound | noproc}.
-spec get_user_context(atom(), session_ref()) -> {ok, term()} | {error, notfound | noproc}.
-spec incoming_connect(binary(), msg_options()) -> {ok, {session_ref(), binary()}} | {error, incomplete_packet} | {error, term()}.
-spec incoming_connect(atom(), binary(), msg_options()) -> {ok, {session_ref(), binary()}} | {error, incomplete_packet} | {error, term()}.
-spec incoming_data(session_ref(), binary()) -> ok | {error, wrong_connection | mqtt_packet_map:decode_error()}.
-spec publish(mqtt_packet_map:mqtt_packet(), term()) -> ok | {error, eacces | invalid_topic}.
-spec publish(topic(), term(), term()) -> ok | {error, eacces | invalid_topic}; (atom(), mqtt_packet_map:mqtt_packet(), term()) -> ok | {error, eacces | invalid_topic}.
-spec publish(atom(), topic(), term(), term()) -> ok | {error, eacces | invalid_topic}.
-spec publish(atom(), topic(), term(), map(), term()) -> ok | {error, eacces | invalid_topic}.
-spec router_info(atom()) -> list().
-spec runtime() -> atom().
-spec session_count(atom()) -> integer().
-spec set_runtime(atom()) -> ok.
-spec set_user_context(session_ref(), term()) -> {ok, term()} | {error, notfound | noproc}.
-spec set_user_context(atom(), session_ref(), term()) -> {ok, term()} | {error, notfound | noproc}.
-spec sidejobs_limit() -> pos_integer().
-spec sidejobs_per_session() -> pos_integer().
-spec start() -> {ok, pid()} | {error, term()}.
-spec start(application:start_type(), term()) -> {ok, pid()} | {error, term()}.
-spec stop(term()) -> ok.
-spec subscribe(topic(), term()) -> ok | {error, eacces | invalid_topic}.
-spec subscribe(atom(), topic(), term()) -> ok | {error, eacces | invalid_topic}.
Link to this function
subscribe(Pool, TopicFilter, Receiver, OwnerPid, Options, UserContext)
View Source-spec temp_response_topic(term()) -> {ok, topic()} | {error, eacces}.
-spec temp_response_topic(atom(), term()) -> {ok, topic()} | {error, eacces}.
-spec unsubscribe(topic()) -> ok | {error, notfound | invalid_topic}.
-spec unsubscribe(atom(), topic()) -> ok | {error, notfound | invalid_topic}.
-spec unsubscribe(atom(), topic(), pid()) -> ok | {error, notfound | invalid_topic}.
-spec update_user_context(session_ref(), fun((term()) -> term())) -> {ok, term()} | {error, notfound | noproc}.
-spec update_user_context(atom(), session_ref(), fun((term()) -> term())) -> {ok, term()} | {error, notfound | noproc}.