Skip to content

Common API¤

This document describes aMQTT common API both used by MQTT Client and Broker.

ApplicationMessage¤

ApplicationMessage ¤

ApplicationMessage(
    packet_id: int | None,
    topic: str,
    qos: int | None,
    data: bytes | bytearray,
    retain: bool,
)

ApplicationMessage and subclasses are used to store published message information flow.

These objects can contain different information depending on the way they were created (incoming or outgoing) and the quality of service used between peers.

Methods:

Attributes:

  • data (bytes | bytearray) –

    Publish message payload data

  • packet_id (int | None) –

    Publish message packet identifier

  • puback_packet (Any | None) –

    :class:amqtt.mqtt.puback.PubackPacket instance corresponding to the

  • pubcomp_packet (Any | None) –

    :class:amqtt.mqtt.puback.PubrelPacket instance corresponding to the

  • publish_packet (PublishPacket | None) –

    :class:amqtt.mqtt.publish.PublishPacket instance corresponding to the

  • pubrec_packet (Any | None) –

    :class:amqtt.mqtt.puback.PubrecPacket instance corresponding to the

  • pubrel_packet (Any | None) –

    :class:amqtt.mqtt.puback.PubrelPacket instance corresponding to the

  • qos (int | None) –

    Publish message Quality of Service

  • retain (bool) –

    Publish message retain flag

  • topic (str) –

    Publish message topic

data instance-attribute ¤

data: bytes | bytearray = data

Publish message payload data

packet_id instance-attribute ¤

packet_id: int | None = packet_id

puback_packet instance-attribute ¤

puback_packet: Any | None = None

:class:amqtt.mqtt.puback.PubackPacket instance corresponding to the PUBACK <http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html#_Toc398718043>_ packet in the messages flow. None if QoS != QOS_1 or if the PUBACK packet has not already been received or sent.

pubcomp_packet instance-attribute ¤

pubcomp_packet: Any | None = None

:class:amqtt.mqtt.puback.PubrelPacket instance corresponding to the PUBCOMP <http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html#_Toc398718058>_ packet in the messages flow. None if QoS != QOS_2 or if the PUBCOMP packet has not already been received or sent.

publish_packet instance-attribute ¤

publish_packet: PublishPacket | None = None

:class:amqtt.mqtt.publish.PublishPacket instance corresponding to the PUBLISH <http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html#_Toc398718037>_ packet in the messages flow. None if the PUBLISH packet has not already been received or sent.

pubrec_packet instance-attribute ¤

pubrec_packet: Any | None = None

:class:amqtt.mqtt.puback.PubrecPacket instance corresponding to the PUBREC <http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html#_Toc398718048>_ packet in the messages flow. None if QoS != QOS_2 or if the PUBREC packet has not already been received or sent.

pubrel_packet instance-attribute ¤

pubrel_packet: Any | None = None

:class:amqtt.mqtt.puback.PubrelPacket instance corresponding to the PUBREL <http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html#_Toc398718053>_ packet in the messages flow. None if QoS != QOS_2 or if the PUBREL packet has not already been received or sent.

qos instance-attribute ¤

qos: int | None = qos

Publish message Quality of Service

retain instance-attribute ¤

retain: bool = retain

Publish message retain flag

topic instance-attribute ¤

topic: str = topic

Publish message topic

build_publish_packet ¤

build_publish_packet(dup: bool = False) -> PublishPacket

Build :class:amqtt.mqtt.publish.PublishPacket from attributes.

:param dup: force dup flag :return: :class:amqtt.mqtt.publish.PublishPacket built from ApplicationMessage instance attributes

IncomingApplicationMessage¤

Represents messages received from MQTT clients.

IncomingApplicationMessage ¤

IncomingApplicationMessage(
    packet_id: int | None,
    topic: str,
    qos: int | None,
    data: bytes,
    retain: bool,
)

Bases: ApplicationMessage

Incoming :class:~amqtt.session.ApplicationMessage.

Methods:

Attributes:

  • data (bytes | bytearray) –

    Publish message payload data

  • packet_id (int | None) –

    Publish message packet identifier

  • puback_packet (Any | None) –

    :class:amqtt.mqtt.puback.PubackPacket instance corresponding to the

  • pubcomp_packet (Any | None) –

    :class:amqtt.mqtt.puback.PubrelPacket instance corresponding to the

  • publish_packet (PublishPacket | None) –

    :class:amqtt.mqtt.publish.PublishPacket instance corresponding to the

  • pubrec_packet (Any | None) –

    :class:amqtt.mqtt.puback.PubrecPacket instance corresponding to the

  • pubrel_packet (Any | None) –

    :class:amqtt.mqtt.puback.PubrelPacket instance corresponding to the

  • qos (int | None) –

    Publish message Quality of Service

  • retain (bool) –

    Publish message retain flag

  • topic (str) –

    Publish message topic

data instance-attribute ¤

data: bytes | bytearray = data

Publish message payload data

packet_id instance-attribute ¤

packet_id: int | None = packet_id

puback_packet instance-attribute ¤

puback_packet: Any | None = None

:class:amqtt.mqtt.puback.PubackPacket instance corresponding to the PUBACK <http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html#_Toc398718043>_ packet in the messages flow. None if QoS != QOS_1 or if the PUBACK packet has not already been received or sent.

pubcomp_packet instance-attribute ¤

pubcomp_packet: Any | None = None

:class:amqtt.mqtt.puback.PubrelPacket instance corresponding to the PUBCOMP <http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html#_Toc398718058>_ packet in the messages flow. None if QoS != QOS_2 or if the PUBCOMP packet has not already been received or sent.

publish_packet instance-attribute ¤

publish_packet: PublishPacket | None = None

:class:amqtt.mqtt.publish.PublishPacket instance corresponding to the PUBLISH <http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html#_Toc398718037>_ packet in the messages flow. None if the PUBLISH packet has not already been received or sent.

pubrec_packet instance-attribute ¤

pubrec_packet: Any | None = None

:class:amqtt.mqtt.puback.PubrecPacket instance corresponding to the PUBREC <http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html#_Toc398718048>_ packet in the messages flow. None if QoS != QOS_2 or if the PUBREC packet has not already been received or sent.

pubrel_packet instance-attribute ¤

pubrel_packet: Any | None = None

:class:amqtt.mqtt.puback.PubrelPacket instance corresponding to the PUBREL <http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html#_Toc398718053>_ packet in the messages flow. None if QoS != QOS_2 or if the PUBREL packet has not already been received or sent.

qos instance-attribute ¤

qos: int | None = qos

Publish message Quality of Service

retain instance-attribute ¤

retain: bool = retain

Publish message retain flag

topic instance-attribute ¤

topic: str = topic

Publish message topic

build_publish_packet ¤

build_publish_packet(dup: bool = False) -> PublishPacket

Build :class:amqtt.mqtt.publish.PublishPacket from attributes.

:param dup: force dup flag :return: :class:amqtt.mqtt.publish.PublishPacket built from ApplicationMessage instance attributes

OutgoingApplicationMessage¤

Inherits from ApplicationMessage. Represents messages to be sent to MQTT clients.

OutgoingApplicationMessage ¤

OutgoingApplicationMessage(
    packet_id: int | None,
    topic: str,
    qos: int | None,
    data: bytes | bytearray,
    retain: bool,
)

Bases: ApplicationMessage

Outgoing :class:~amqtt.session.ApplicationMessage.

Methods:

Attributes:

  • data (bytes | bytearray) –

    Publish message payload data

  • packet_id (int | None) –

    Publish message packet identifier

  • puback_packet (Any | None) –

    :class:amqtt.mqtt.puback.PubackPacket instance corresponding to the

  • pubcomp_packet (Any | None) –

    :class:amqtt.mqtt.puback.PubrelPacket instance corresponding to the

  • publish_packet (PublishPacket | None) –

    :class:amqtt.mqtt.publish.PublishPacket instance corresponding to the

  • pubrec_packet (Any | None) –

    :class:amqtt.mqtt.puback.PubrecPacket instance corresponding to the

  • pubrel_packet (Any | None) –

    :class:amqtt.mqtt.puback.PubrelPacket instance corresponding to the

  • qos (int | None) –

    Publish message Quality of Service

  • retain (bool) –

    Publish message retain flag

  • topic (str) –

    Publish message topic

data instance-attribute ¤

data: bytes | bytearray = data

Publish message payload data

packet_id instance-attribute ¤

packet_id: int | None = packet_id

puback_packet instance-attribute ¤

puback_packet: Any | None = None

:class:amqtt.mqtt.puback.PubackPacket instance corresponding to the PUBACK <http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html#_Toc398718043>_ packet in the messages flow. None if QoS != QOS_1 or if the PUBACK packet has not already been received or sent.

pubcomp_packet instance-attribute ¤

pubcomp_packet: Any | None = None

:class:amqtt.mqtt.puback.PubrelPacket instance corresponding to the PUBCOMP <http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html#_Toc398718058>_ packet in the messages flow. None if QoS != QOS_2 or if the PUBCOMP packet has not already been received or sent.

publish_packet instance-attribute ¤

publish_packet: PublishPacket | None = None

:class:amqtt.mqtt.publish.PublishPacket instance corresponding to the PUBLISH <http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html#_Toc398718037>_ packet in the messages flow. None if the PUBLISH packet has not already been received or sent.

pubrec_packet instance-attribute ¤

pubrec_packet: Any | None = None

:class:amqtt.mqtt.puback.PubrecPacket instance corresponding to the PUBREC <http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html#_Toc398718048>_ packet in the messages flow. None if QoS != QOS_2 or if the PUBREC packet has not already been received or sent.

pubrel_packet instance-attribute ¤

pubrel_packet: Any | None = None

:class:amqtt.mqtt.puback.PubrelPacket instance corresponding to the PUBREL <http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html#_Toc398718053>_ packet in the messages flow. None if QoS != QOS_2 or if the PUBREL packet has not already been received or sent.

qos instance-attribute ¤

qos: int | None = qos

Publish message Quality of Service

retain instance-attribute ¤

retain: bool = retain

Publish message retain flag

topic instance-attribute ¤

topic: str = topic

Publish message topic

build_publish_packet ¤

build_publish_packet(dup: bool = False) -> PublishPacket

Build :class:amqtt.mqtt.publish.PublishPacket from attributes.

:param dup: force dup flag :return: :class:amqtt.mqtt.publish.PublishPacket built from ApplicationMessage instance attributes