MQTT 5.0 bidirectional Topic Alias table.
inboundmaps broker-assigned alias integers to topic names (bounded by the client'stopic_alias_maximum).outboundmaps topic names to client-assigned alias integers (bounded by the broker'stopic_alias_maximumreceived in CONNACK).
Summary
Functions
Applies automatic outbound Topic Alias compression for a PUBLISH packet.
Creates a fresh TopicAlias table (reset on every new network connection).
Resets all alias mappings (required by MQTT 5.0 spec on disconnect/reconnect).
Resolves an incoming PUBLISH topic and optional :topic_alias property.
Types
@type t() :: %ExMqtt.State.TopicAlias{ inbound: %{optional(pos_integer()) => String.t()}, inbound_max: non_neg_integer(), next_outbound_alias: pos_integer(), outbound: %{optional(String.t()) => pos_integer()}, outbound_max: non_neg_integer() }
Functions
Applies automatic outbound Topic Alias compression for a PUBLISH packet.
- If the broker advertised
outbound_max == 0or the caller already set:topic_alias, the topic and properties are left unchanged. - On first publish of a topic (while
next_outbound_alias <= outbound_max), registers the alias and keeps the full topic name +topic_alias: alias_id. - On subsequent publishes of that same topic on the same connection, replaces the
wire topic with
""and setstopic_alias: alias_id.
@spec new(non_neg_integer(), non_neg_integer()) :: t()
Creates a fresh TopicAlias table (reset on every new network connection).
@spec reset(t(), non_neg_integer()) :: t()
Resets all alias mappings (required by MQTT 5.0 spec on disconnect/reconnect).
@spec resolve_inbound(t(), String.t(), pos_integer() | nil) :: {:ok, String.t(), t()} | {:error, :topic_alias_invalid}
Resolves an incoming PUBLISH topic and optional :topic_alias property.