kopia lustrzana https://github.com/Yakifo/amqtt
rename hbmqtt -> amqtt in module itself
rodzic
478a2d18c8
commit
d86918216a
|
|
@ -12,11 +12,11 @@ from collections import deque
|
||||||
|
|
||||||
from functools import partial
|
from functools import partial
|
||||||
from transitions import Machine, MachineError
|
from transitions import Machine, MachineError
|
||||||
from hbmqtt.session import Session
|
from amqtt.session import Session
|
||||||
from hbmqtt.mqtt.protocol.broker_handler import BrokerProtocolHandler
|
from amqtt.mqtt.protocol.broker_handler import BrokerProtocolHandler
|
||||||
from hbmqtt.errors import HBMQTTException, MQTTException
|
from amqtt.errors import HBMQTTException, MQTTException
|
||||||
from hbmqtt.utils import format_client_message, gen_client_id
|
from amqtt.utils import format_client_message, gen_client_id
|
||||||
from hbmqtt.adapters import (
|
from amqtt.adapters import (
|
||||||
StreamReaderAdapter,
|
StreamReaderAdapter,
|
||||||
StreamWriterAdapter,
|
StreamWriterAdapter,
|
||||||
ReaderAdapter,
|
ReaderAdapter,
|
||||||
|
|
|
||||||
|
|
@ -9,18 +9,18 @@ import copy
|
||||||
from urllib.parse import urlparse, urlunparse
|
from urllib.parse import urlparse, urlunparse
|
||||||
from functools import wraps
|
from functools import wraps
|
||||||
|
|
||||||
from hbmqtt.session import Session
|
from amqtt.session import Session
|
||||||
from hbmqtt.mqtt.connack import CONNECTION_ACCEPTED
|
from amqtt.mqtt.connack import CONNECTION_ACCEPTED
|
||||||
from hbmqtt.mqtt.protocol.client_handler import ClientProtocolHandler
|
from amqtt.mqtt.protocol.client_handler import ClientProtocolHandler
|
||||||
from hbmqtt.adapters import (
|
from amqtt.adapters import (
|
||||||
StreamReaderAdapter,
|
StreamReaderAdapter,
|
||||||
StreamWriterAdapter,
|
StreamWriterAdapter,
|
||||||
WebSocketsReader,
|
WebSocketsReader,
|
||||||
WebSocketsWriter,
|
WebSocketsWriter,
|
||||||
)
|
)
|
||||||
from hbmqtt.plugins.manager import PluginManager, BaseContext
|
from amqtt.plugins.manager import PluginManager, BaseContext
|
||||||
from hbmqtt.mqtt.protocol.handler import ProtocolHandlerException
|
from amqtt.mqtt.protocol.handler import ProtocolHandlerException
|
||||||
from hbmqtt.mqtt.constants import QOS_0, QOS_1, QOS_2
|
from amqtt.mqtt.constants import QOS_0, QOS_1, QOS_2
|
||||||
import websockets
|
import websockets
|
||||||
from websockets.uri import InvalidURI
|
from websockets.uri import InvalidURI
|
||||||
from websockets.exceptions import InvalidHandshake
|
from websockets.exceptions import InvalidHandshake
|
||||||
|
|
@ -90,7 +90,7 @@ class MQTTClient:
|
||||||
|
|
||||||
MQTTClient instances provides API for connecting to a broker and send/receive messages using the MQTT protocol.
|
MQTTClient instances provides API for connecting to a broker and send/receive messages using the MQTT protocol.
|
||||||
|
|
||||||
:param client_id: MQTT client ID to use when connecting to the broker. If none, it will generated randomly by :func:`hbmqtt.utils.gen_client_id`
|
:param client_id: MQTT client ID to use when connecting to the broker. If none, it will generated randomly by :func:`amqtt.utils.gen_client_id`
|
||||||
:param config: Client configuration
|
:param config: Client configuration
|
||||||
:param loop: asynio loop to use
|
:param loop: asynio loop to use
|
||||||
:return: class instance
|
:return: class instance
|
||||||
|
|
@ -104,7 +104,7 @@ class MQTTClient:
|
||||||
if client_id is not None:
|
if client_id is not None:
|
||||||
self.client_id = client_id
|
self.client_id = client_id
|
||||||
else:
|
else:
|
||||||
from hbmqtt.utils import gen_client_id
|
from amqtt.utils import gen_client_id
|
||||||
|
|
||||||
self.client_id = gen_client_id()
|
self.client_id = gen_client_id()
|
||||||
self.logger.debug("Using generated client ID : %s" % self.client_id)
|
self.logger.debug("Using generated client ID : %s" % self.client_id)
|
||||||
|
|
@ -151,7 +151,7 @@ class MQTTClient:
|
||||||
:param cadata: server certificate authority data (optional, used for secured connection)
|
:param cadata: server certificate authority data (optional, used for secured connection)
|
||||||
:param extra_headers: a dictionary with additional http headers that should be sent on the initial connection (optional, used only with websocket connections)
|
:param extra_headers: a dictionary with additional http headers that should be sent on the initial connection (optional, used only with websocket connections)
|
||||||
:return: `CONNACK <http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html#_Toc398718033>`_ return code
|
:return: `CONNACK <http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html#_Toc398718033>`_ return code
|
||||||
:raise: :class:`hbmqtt.client.ConnectException` if connection fails
|
:raise: :class:`amqtt.client.ConnectException` if connection fails
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if extra_headers is None:
|
if extra_headers is None:
|
||||||
|
|
@ -217,7 +217,7 @@ class MQTTClient:
|
||||||
|
|
||||||
:param cleansession: clean session flag used in MQTT CONNECT messages sent for reconnections.
|
:param cleansession: clean session flag used in MQTT CONNECT messages sent for reconnections.
|
||||||
:return: `CONNACK <http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html#_Toc398718033>`_ return code
|
:return: `CONNACK <http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html#_Toc398718033>`_ return code
|
||||||
:raise: :class:`hbmqtt.client.ConnectException` if re-connection fails after max retries.
|
:raise: :class:`amqtt.client.ConnectException` if re-connection fails after max retries.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if self.session.transitions.is_connected():
|
if self.session.transitions.is_connected():
|
||||||
|
|
@ -364,7 +364,7 @@ class MQTTClient:
|
||||||
This method is a *coroutine*.
|
This method is a *coroutine*.
|
||||||
|
|
||||||
:param timeout: maximum number of seconds to wait before returning. If timeout is not specified or None, there is no limit to the wait time until next message arrives.
|
:param timeout: maximum number of seconds to wait before returning. If timeout is not specified or None, there is no limit to the wait time until next message arrives.
|
||||||
:return: instance of :class:`hbmqtt.session.ApplicationMessage` containing received message information flow.
|
:return: instance of :class:`amqtt.session.ApplicationMessage` containing received message information flow.
|
||||||
:raises: :class:`asyncio.TimeoutError` if timeout occurs before a message is delivered
|
:raises: :class:`asyncio.TimeoutError` if timeout occurs before a message is delivered
|
||||||
"""
|
"""
|
||||||
deliver_task = asyncio.ensure_future(
|
deliver_task = asyncio.ensure_future(
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
# See the file license.txt for copying permission.
|
# See the file license.txt for copying permission.
|
||||||
import asyncio
|
import asyncio
|
||||||
from struct import pack, unpack
|
from struct import pack, unpack
|
||||||
from hbmqtt.errors import NoDataException
|
from amqtt.errors import NoDataException
|
||||||
|
|
||||||
|
|
||||||
def bytes_to_hex_str(data):
|
def bytes_to_hex_str(data):
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
# Copyright (c) 2015 Nicolas JOUANIN
|
# Copyright (c) 2015 Nicolas JOUANIN
|
||||||
#
|
#
|
||||||
# See the file license.txt for copying permission.
|
# See the file license.txt for copying permission.
|
||||||
from hbmqtt.errors import HBMQTTException
|
from amqtt.errors import HBMQTTException
|
||||||
from hbmqtt.mqtt.packet import (
|
from amqtt.mqtt.packet import (
|
||||||
CONNECT,
|
CONNECT,
|
||||||
CONNACK,
|
CONNACK,
|
||||||
PUBLISH,
|
PUBLISH,
|
||||||
|
|
@ -19,20 +19,20 @@ from hbmqtt.mqtt.packet import (
|
||||||
DISCONNECT,
|
DISCONNECT,
|
||||||
MQTTFixedHeader,
|
MQTTFixedHeader,
|
||||||
)
|
)
|
||||||
from hbmqtt.mqtt.connect import ConnectPacket
|
from amqtt.mqtt.connect import ConnectPacket
|
||||||
from hbmqtt.mqtt.connack import ConnackPacket
|
from amqtt.mqtt.connack import ConnackPacket
|
||||||
from hbmqtt.mqtt.disconnect import DisconnectPacket
|
from amqtt.mqtt.disconnect import DisconnectPacket
|
||||||
from hbmqtt.mqtt.pingreq import PingReqPacket
|
from amqtt.mqtt.pingreq import PingReqPacket
|
||||||
from hbmqtt.mqtt.pingresp import PingRespPacket
|
from amqtt.mqtt.pingresp import PingRespPacket
|
||||||
from hbmqtt.mqtt.publish import PublishPacket
|
from amqtt.mqtt.publish import PublishPacket
|
||||||
from hbmqtt.mqtt.puback import PubackPacket
|
from amqtt.mqtt.puback import PubackPacket
|
||||||
from hbmqtt.mqtt.pubrec import PubrecPacket
|
from amqtt.mqtt.pubrec import PubrecPacket
|
||||||
from hbmqtt.mqtt.pubrel import PubrelPacket
|
from amqtt.mqtt.pubrel import PubrelPacket
|
||||||
from hbmqtt.mqtt.pubcomp import PubcompPacket
|
from amqtt.mqtt.pubcomp import PubcompPacket
|
||||||
from hbmqtt.mqtt.subscribe import SubscribePacket
|
from amqtt.mqtt.subscribe import SubscribePacket
|
||||||
from hbmqtt.mqtt.suback import SubackPacket
|
from amqtt.mqtt.suback import SubackPacket
|
||||||
from hbmqtt.mqtt.unsubscribe import UnsubscribePacket
|
from amqtt.mqtt.unsubscribe import UnsubscribePacket
|
||||||
from hbmqtt.mqtt.unsuback import UnsubackPacket
|
from amqtt.mqtt.unsuback import UnsubackPacket
|
||||||
|
|
||||||
packet_dict = {
|
packet_dict = {
|
||||||
CONNECT: ConnectPacket,
|
CONNECT: ConnectPacket,
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
# Copyright (c) 2015 Nicolas JOUANIN
|
# Copyright (c) 2015 Nicolas JOUANIN
|
||||||
#
|
#
|
||||||
# See the file license.txt for copying permission.
|
# See the file license.txt for copying permission.
|
||||||
from hbmqtt.mqtt.packet import CONNACK, MQTTPacket, MQTTFixedHeader, MQTTVariableHeader
|
from amqtt.mqtt.packet import CONNACK, MQTTPacket, MQTTFixedHeader, MQTTVariableHeader
|
||||||
from hbmqtt.codecs import read_or_raise, bytes_to_int
|
from amqtt.codecs import read_or_raise, bytes_to_int
|
||||||
from hbmqtt.errors import HBMQTTException
|
from amqtt.errors import HBMQTTException
|
||||||
from hbmqtt.adapters import ReaderAdapter
|
from amqtt.adapters import ReaderAdapter
|
||||||
|
|
||||||
CONNECTION_ACCEPTED = 0x00
|
CONNECTION_ACCEPTED = 0x00
|
||||||
UNACCEPTABLE_PROTOCOL_VERSION = 0x01
|
UNACCEPTABLE_PROTOCOL_VERSION = 0x01
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
#
|
#
|
||||||
# See the file license.txt for copying permission.
|
# See the file license.txt for copying permission.
|
||||||
|
|
||||||
from hbmqtt.codecs import (
|
from amqtt.codecs import (
|
||||||
bytes_to_int,
|
bytes_to_int,
|
||||||
decode_data_with_length,
|
decode_data_with_length,
|
||||||
decode_string,
|
decode_string,
|
||||||
|
|
@ -11,16 +11,16 @@ from hbmqtt.codecs import (
|
||||||
int_to_bytes,
|
int_to_bytes,
|
||||||
read_or_raise,
|
read_or_raise,
|
||||||
)
|
)
|
||||||
from hbmqtt.mqtt.packet import (
|
from amqtt.mqtt.packet import (
|
||||||
MQTTPacket,
|
MQTTPacket,
|
||||||
MQTTFixedHeader,
|
MQTTFixedHeader,
|
||||||
CONNECT,
|
CONNECT,
|
||||||
MQTTVariableHeader,
|
MQTTVariableHeader,
|
||||||
MQTTPayload,
|
MQTTPayload,
|
||||||
)
|
)
|
||||||
from hbmqtt.errors import HBMQTTException, NoDataException
|
from amqtt.errors import HBMQTTException, NoDataException
|
||||||
from hbmqtt.adapters import ReaderAdapter
|
from amqtt.adapters import ReaderAdapter
|
||||||
from hbmqtt.utils import gen_client_id
|
from amqtt.utils import gen_client_id
|
||||||
|
|
||||||
|
|
||||||
class ConnectVariableHeader(MQTTVariableHeader):
|
class ConnectVariableHeader(MQTTVariableHeader):
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
# Copyright (c) 2015 Nicolas JOUANIN
|
# Copyright (c) 2015 Nicolas JOUANIN
|
||||||
#
|
#
|
||||||
# See the file license.txt for copying permission.
|
# See the file license.txt for copying permission.
|
||||||
from hbmqtt.mqtt.packet import MQTTPacket, MQTTFixedHeader, DISCONNECT
|
from amqtt.mqtt.packet import MQTTPacket, MQTTFixedHeader, DISCONNECT
|
||||||
from hbmqtt.errors import HBMQTTException
|
from amqtt.errors import HBMQTTException
|
||||||
|
|
||||||
|
|
||||||
class DisconnectPacket(MQTTPacket):
|
class DisconnectPacket(MQTTPacket):
|
||||||
|
|
|
||||||
|
|
@ -3,14 +3,14 @@
|
||||||
# See the file license.txt for copying permission.
|
# See the file license.txt for copying permission.
|
||||||
import asyncio
|
import asyncio
|
||||||
|
|
||||||
from hbmqtt.codecs import (
|
from amqtt.codecs import (
|
||||||
bytes_to_hex_str,
|
bytes_to_hex_str,
|
||||||
decode_packet_id,
|
decode_packet_id,
|
||||||
int_to_bytes,
|
int_to_bytes,
|
||||||
read_or_raise,
|
read_or_raise,
|
||||||
)
|
)
|
||||||
from hbmqtt.errors import CodecException, MQTTException, NoDataException
|
from amqtt.errors import CodecException, MQTTException, NoDataException
|
||||||
from hbmqtt.adapters import ReaderAdapter, WriterAdapter
|
from amqtt.adapters import ReaderAdapter, WriterAdapter
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from struct import unpack
|
from struct import unpack
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
# Copyright (c) 2015 Nicolas JOUANIN
|
# Copyright (c) 2015 Nicolas JOUANIN
|
||||||
#
|
#
|
||||||
# See the file license.txt for copying permission.
|
# See the file license.txt for copying permission.
|
||||||
from hbmqtt.mqtt.packet import MQTTPacket, MQTTFixedHeader, PINGREQ
|
from amqtt.mqtt.packet import MQTTPacket, MQTTFixedHeader, PINGREQ
|
||||||
from hbmqtt.errors import HBMQTTException
|
from amqtt.errors import HBMQTTException
|
||||||
|
|
||||||
|
|
||||||
class PingReqPacket(MQTTPacket):
|
class PingReqPacket(MQTTPacket):
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
# Copyright (c) 2015 Nicolas JOUANIN
|
# Copyright (c) 2015 Nicolas JOUANIN
|
||||||
#
|
#
|
||||||
# See the file license.txt for copying permission.
|
# See the file license.txt for copying permission.
|
||||||
from hbmqtt.mqtt.packet import MQTTPacket, MQTTFixedHeader, PINGRESP
|
from amqtt.mqtt.packet import MQTTPacket, MQTTFixedHeader, PINGRESP
|
||||||
from hbmqtt.errors import HBMQTTException
|
from amqtt.errors import HBMQTTException
|
||||||
|
|
||||||
|
|
||||||
class PingRespPacket(MQTTPacket):
|
class PingRespPacket(MQTTPacket):
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,8 @@
|
||||||
#
|
#
|
||||||
# See the file license.txt for copying permission.
|
# See the file license.txt for copying permission.
|
||||||
from asyncio import futures, Queue
|
from asyncio import futures, Queue
|
||||||
from hbmqtt.mqtt.protocol.handler import ProtocolHandler
|
from amqtt.mqtt.protocol.handler import ProtocolHandler
|
||||||
from hbmqtt.mqtt.connack import (
|
from amqtt.mqtt.connack import (
|
||||||
CONNECTION_ACCEPTED,
|
CONNECTION_ACCEPTED,
|
||||||
UNACCEPTABLE_PROTOCOL_VERSION,
|
UNACCEPTABLE_PROTOCOL_VERSION,
|
||||||
IDENTIFIER_REJECTED,
|
IDENTIFIER_REJECTED,
|
||||||
|
|
@ -11,18 +11,18 @@ from hbmqtt.mqtt.connack import (
|
||||||
NOT_AUTHORIZED,
|
NOT_AUTHORIZED,
|
||||||
ConnackPacket,
|
ConnackPacket,
|
||||||
)
|
)
|
||||||
from hbmqtt.mqtt.connect import ConnectPacket
|
from amqtt.mqtt.connect import ConnectPacket
|
||||||
from hbmqtt.mqtt.pingreq import PingReqPacket
|
from amqtt.mqtt.pingreq import PingReqPacket
|
||||||
from hbmqtt.mqtt.pingresp import PingRespPacket
|
from amqtt.mqtt.pingresp import PingRespPacket
|
||||||
from hbmqtt.mqtt.subscribe import SubscribePacket
|
from amqtt.mqtt.subscribe import SubscribePacket
|
||||||
from hbmqtt.mqtt.suback import SubackPacket
|
from amqtt.mqtt.suback import SubackPacket
|
||||||
from hbmqtt.mqtt.unsubscribe import UnsubscribePacket
|
from amqtt.mqtt.unsubscribe import UnsubscribePacket
|
||||||
from hbmqtt.mqtt.unsuback import UnsubackPacket
|
from amqtt.mqtt.unsuback import UnsubackPacket
|
||||||
from hbmqtt.utils import format_client_message
|
from amqtt.utils import format_client_message
|
||||||
from hbmqtt.session import Session
|
from amqtt.session import Session
|
||||||
from hbmqtt.plugins.manager import PluginManager
|
from amqtt.plugins.manager import PluginManager
|
||||||
from hbmqtt.adapters import ReaderAdapter, WriterAdapter
|
from amqtt.adapters import ReaderAdapter, WriterAdapter
|
||||||
from hbmqtt.errors import MQTTException
|
from amqtt.errors import MQTTException
|
||||||
from .handler import EVENT_MQTT_PACKET_RECEIVED, EVENT_MQTT_PACKET_SENT
|
from .handler import EVENT_MQTT_PACKET_RECEIVED, EVENT_MQTT_PACKET_SENT
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,18 +3,18 @@
|
||||||
# See the file license.txt for copying permission.
|
# See the file license.txt for copying permission.
|
||||||
import asyncio
|
import asyncio
|
||||||
from asyncio import futures
|
from asyncio import futures
|
||||||
from hbmqtt.mqtt.protocol.handler import ProtocolHandler, EVENT_MQTT_PACKET_RECEIVED
|
from amqtt.mqtt.protocol.handler import ProtocolHandler, EVENT_MQTT_PACKET_RECEIVED
|
||||||
from hbmqtt.mqtt.disconnect import DisconnectPacket
|
from amqtt.mqtt.disconnect import DisconnectPacket
|
||||||
from hbmqtt.mqtt.pingreq import PingReqPacket
|
from amqtt.mqtt.pingreq import PingReqPacket
|
||||||
from hbmqtt.mqtt.pingresp import PingRespPacket
|
from amqtt.mqtt.pingresp import PingRespPacket
|
||||||
from hbmqtt.mqtt.subscribe import SubscribePacket
|
from amqtt.mqtt.subscribe import SubscribePacket
|
||||||
from hbmqtt.mqtt.suback import SubackPacket
|
from amqtt.mqtt.suback import SubackPacket
|
||||||
from hbmqtt.mqtt.unsubscribe import UnsubscribePacket
|
from amqtt.mqtt.unsubscribe import UnsubscribePacket
|
||||||
from hbmqtt.mqtt.unsuback import UnsubackPacket
|
from amqtt.mqtt.unsuback import UnsubackPacket
|
||||||
from hbmqtt.mqtt.connect import ConnectVariableHeader, ConnectPayload, ConnectPacket
|
from amqtt.mqtt.connect import ConnectVariableHeader, ConnectPayload, ConnectPacket
|
||||||
from hbmqtt.mqtt.connack import ConnackPacket
|
from amqtt.mqtt.connack import ConnackPacket
|
||||||
from hbmqtt.session import Session
|
from amqtt.session import Session
|
||||||
from hbmqtt.plugins.manager import PluginManager
|
from amqtt.plugins.manager import PluginManager
|
||||||
|
|
||||||
|
|
||||||
class ClientProtocolHandler(ProtocolHandler):
|
class ClientProtocolHandler(ProtocolHandler):
|
||||||
|
|
|
||||||
|
|
@ -8,10 +8,10 @@ import itertools
|
||||||
import asyncio
|
import asyncio
|
||||||
from asyncio import InvalidStateError
|
from asyncio import InvalidStateError
|
||||||
|
|
||||||
from hbmqtt.mqtt import packet_class
|
from amqtt.mqtt import packet_class
|
||||||
from hbmqtt.mqtt.connack import ConnackPacket
|
from amqtt.mqtt.connack import ConnackPacket
|
||||||
from hbmqtt.mqtt.connect import ConnectPacket
|
from amqtt.mqtt.connect import ConnectPacket
|
||||||
from hbmqtt.mqtt.packet import (
|
from amqtt.mqtt.packet import (
|
||||||
RESERVED_0,
|
RESERVED_0,
|
||||||
CONNECT,
|
CONNECT,
|
||||||
CONNACK,
|
CONNACK,
|
||||||
|
|
@ -30,29 +30,29 @@ from hbmqtt.mqtt.packet import (
|
||||||
RESERVED_15,
|
RESERVED_15,
|
||||||
MQTTFixedHeader,
|
MQTTFixedHeader,
|
||||||
)
|
)
|
||||||
from hbmqtt.mqtt.pingresp import PingRespPacket
|
from amqtt.mqtt.pingresp import PingRespPacket
|
||||||
from hbmqtt.mqtt.pingreq import PingReqPacket
|
from amqtt.mqtt.pingreq import PingReqPacket
|
||||||
from hbmqtt.mqtt.publish import PublishPacket
|
from amqtt.mqtt.publish import PublishPacket
|
||||||
from hbmqtt.mqtt.pubrel import PubrelPacket
|
from amqtt.mqtt.pubrel import PubrelPacket
|
||||||
from hbmqtt.mqtt.puback import PubackPacket
|
from amqtt.mqtt.puback import PubackPacket
|
||||||
from hbmqtt.mqtt.pubrec import PubrecPacket
|
from amqtt.mqtt.pubrec import PubrecPacket
|
||||||
from hbmqtt.mqtt.pubcomp import PubcompPacket
|
from amqtt.mqtt.pubcomp import PubcompPacket
|
||||||
from hbmqtt.mqtt.suback import SubackPacket
|
from amqtt.mqtt.suback import SubackPacket
|
||||||
from hbmqtt.mqtt.subscribe import SubscribePacket
|
from amqtt.mqtt.subscribe import SubscribePacket
|
||||||
from hbmqtt.mqtt.unsubscribe import UnsubscribePacket
|
from amqtt.mqtt.unsubscribe import UnsubscribePacket
|
||||||
from hbmqtt.mqtt.unsuback import UnsubackPacket
|
from amqtt.mqtt.unsuback import UnsubackPacket
|
||||||
from hbmqtt.mqtt.disconnect import DisconnectPacket
|
from amqtt.mqtt.disconnect import DisconnectPacket
|
||||||
from hbmqtt.adapters import ReaderAdapter, WriterAdapter
|
from amqtt.adapters import ReaderAdapter, WriterAdapter
|
||||||
from hbmqtt.session import (
|
from amqtt.session import (
|
||||||
Session,
|
Session,
|
||||||
OutgoingApplicationMessage,
|
OutgoingApplicationMessage,
|
||||||
IncomingApplicationMessage,
|
IncomingApplicationMessage,
|
||||||
INCOMING,
|
INCOMING,
|
||||||
OUTGOING,
|
OUTGOING,
|
||||||
)
|
)
|
||||||
from hbmqtt.mqtt.constants import QOS_0, QOS_1, QOS_2
|
from amqtt.mqtt.constants import QOS_0, QOS_1, QOS_2
|
||||||
from hbmqtt.plugins.manager import PluginManager
|
from amqtt.plugins.manager import PluginManager
|
||||||
from hbmqtt.errors import HBMQTTException, MQTTException, NoDataException
|
from amqtt.errors import HBMQTTException, MQTTException, NoDataException
|
||||||
|
|
||||||
|
|
||||||
EVENT_MQTT_PACKET_SENT = "mqtt_packet_sent"
|
EVENT_MQTT_PACKET_SENT = "mqtt_packet_sent"
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,13 @@
|
||||||
# Copyright (c) 2015 Nicolas JOUANIN
|
# Copyright (c) 2015 Nicolas JOUANIN
|
||||||
#
|
#
|
||||||
# See the file license.txt for copying permission.
|
# See the file license.txt for copying permission.
|
||||||
from hbmqtt.mqtt.packet import (
|
from amqtt.mqtt.packet import (
|
||||||
MQTTPacket,
|
MQTTPacket,
|
||||||
MQTTFixedHeader,
|
MQTTFixedHeader,
|
||||||
PUBACK,
|
PUBACK,
|
||||||
PacketIdVariableHeader,
|
PacketIdVariableHeader,
|
||||||
)
|
)
|
||||||
from hbmqtt.errors import HBMQTTException
|
from amqtt.errors import HBMQTTException
|
||||||
|
|
||||||
|
|
||||||
class PubackPacket(MQTTPacket):
|
class PubackPacket(MQTTPacket):
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,13 @@
|
||||||
# Copyright (c) 2015 Nicolas JOUANIN
|
# Copyright (c) 2015 Nicolas JOUANIN
|
||||||
#
|
#
|
||||||
# See the file license.txt for copying permission.
|
# See the file license.txt for copying permission.
|
||||||
from hbmqtt.mqtt.packet import (
|
from amqtt.mqtt.packet import (
|
||||||
MQTTPacket,
|
MQTTPacket,
|
||||||
MQTTFixedHeader,
|
MQTTFixedHeader,
|
||||||
PUBCOMP,
|
PUBCOMP,
|
||||||
PacketIdVariableHeader,
|
PacketIdVariableHeader,
|
||||||
)
|
)
|
||||||
from hbmqtt.errors import HBMQTTException
|
from amqtt.errors import HBMQTTException
|
||||||
|
|
||||||
|
|
||||||
class PubcompPacket(MQTTPacket):
|
class PubcompPacket(MQTTPacket):
|
||||||
|
|
|
||||||
|
|
@ -3,15 +3,15 @@
|
||||||
# See the file license.txt for copying permission.
|
# See the file license.txt for copying permission.
|
||||||
import asyncio
|
import asyncio
|
||||||
|
|
||||||
from hbmqtt.mqtt.packet import (
|
from amqtt.mqtt.packet import (
|
||||||
MQTTPacket,
|
MQTTPacket,
|
||||||
MQTTFixedHeader,
|
MQTTFixedHeader,
|
||||||
PUBLISH,
|
PUBLISH,
|
||||||
MQTTVariableHeader,
|
MQTTVariableHeader,
|
||||||
MQTTPayload,
|
MQTTPayload,
|
||||||
)
|
)
|
||||||
from hbmqtt.errors import HBMQTTException, MQTTException
|
from amqtt.errors import HBMQTTException, MQTTException
|
||||||
from hbmqtt.codecs import decode_packet_id, decode_string, encode_string, int_to_bytes
|
from amqtt.codecs import decode_packet_id, decode_string, encode_string, int_to_bytes
|
||||||
|
|
||||||
|
|
||||||
class PublishVariableHeader(MQTTVariableHeader):
|
class PublishVariableHeader(MQTTVariableHeader):
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,13 @@
|
||||||
# Copyright (c) 2015 Nicolas JOUANIN
|
# Copyright (c) 2015 Nicolas JOUANIN
|
||||||
#
|
#
|
||||||
# See the file license.txt for copying permission.
|
# See the file license.txt for copying permission.
|
||||||
from hbmqtt.mqtt.packet import (
|
from amqtt.mqtt.packet import (
|
||||||
MQTTPacket,
|
MQTTPacket,
|
||||||
MQTTFixedHeader,
|
MQTTFixedHeader,
|
||||||
PUBREC,
|
PUBREC,
|
||||||
PacketIdVariableHeader,
|
PacketIdVariableHeader,
|
||||||
)
|
)
|
||||||
from hbmqtt.errors import HBMQTTException
|
from amqtt.errors import HBMQTTException
|
||||||
|
|
||||||
|
|
||||||
class PubrecPacket(MQTTPacket):
|
class PubrecPacket(MQTTPacket):
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,13 @@
|
||||||
# Copyright (c) 2015 Nicolas JOUANIN
|
# Copyright (c) 2015 Nicolas JOUANIN
|
||||||
#
|
#
|
||||||
# See the file license.txt for copying permission.
|
# See the file license.txt for copying permission.
|
||||||
from hbmqtt.mqtt.packet import (
|
from amqtt.mqtt.packet import (
|
||||||
MQTTPacket,
|
MQTTPacket,
|
||||||
MQTTFixedHeader,
|
MQTTFixedHeader,
|
||||||
PUBREL,
|
PUBREL,
|
||||||
PacketIdVariableHeader,
|
PacketIdVariableHeader,
|
||||||
)
|
)
|
||||||
from hbmqtt.errors import HBMQTTException
|
from amqtt.errors import HBMQTTException
|
||||||
|
|
||||||
|
|
||||||
class PubrelPacket(MQTTPacket):
|
class PubrelPacket(MQTTPacket):
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
# Copyright (c) 2015 Nicolas JOUANIN
|
# Copyright (c) 2015 Nicolas JOUANIN
|
||||||
#
|
#
|
||||||
# See the file license.txt for copying permission.
|
# See the file license.txt for copying permission.
|
||||||
from hbmqtt.mqtt.packet import (
|
from amqtt.mqtt.packet import (
|
||||||
MQTTPacket,
|
MQTTPacket,
|
||||||
MQTTFixedHeader,
|
MQTTFixedHeader,
|
||||||
SUBACK,
|
SUBACK,
|
||||||
|
|
@ -9,9 +9,9 @@ from hbmqtt.mqtt.packet import (
|
||||||
MQTTPayload,
|
MQTTPayload,
|
||||||
MQTTVariableHeader,
|
MQTTVariableHeader,
|
||||||
)
|
)
|
||||||
from hbmqtt.errors import HBMQTTException, NoDataException
|
from amqtt.errors import HBMQTTException, NoDataException
|
||||||
from hbmqtt.adapters import ReaderAdapter
|
from amqtt.adapters import ReaderAdapter
|
||||||
from hbmqtt.codecs import bytes_to_int, int_to_bytes, read_or_raise
|
from amqtt.codecs import bytes_to_int, int_to_bytes, read_or_raise
|
||||||
|
|
||||||
|
|
||||||
class SubackPayload(MQTTPayload):
|
class SubackPayload(MQTTPayload):
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
# See the file license.txt for copying permission.
|
# See the file license.txt for copying permission.
|
||||||
import asyncio
|
import asyncio
|
||||||
|
|
||||||
from hbmqtt.mqtt.packet import (
|
from amqtt.mqtt.packet import (
|
||||||
MQTTPacket,
|
MQTTPacket,
|
||||||
MQTTFixedHeader,
|
MQTTFixedHeader,
|
||||||
SUBSCRIBE,
|
SUBSCRIBE,
|
||||||
|
|
@ -11,8 +11,8 @@ from hbmqtt.mqtt.packet import (
|
||||||
MQTTPayload,
|
MQTTPayload,
|
||||||
MQTTVariableHeader,
|
MQTTVariableHeader,
|
||||||
)
|
)
|
||||||
from hbmqtt.errors import HBMQTTException, NoDataException
|
from amqtt.errors import HBMQTTException, NoDataException
|
||||||
from hbmqtt.codecs import (
|
from amqtt.codecs import (
|
||||||
bytes_to_int,
|
bytes_to_int,
|
||||||
decode_string,
|
decode_string,
|
||||||
encode_string,
|
encode_string,
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,13 @@
|
||||||
# Copyright (c) 2015 Nicolas JOUANIN
|
# Copyright (c) 2015 Nicolas JOUANIN
|
||||||
#
|
#
|
||||||
# See the file license.txt for copying permission.
|
# See the file license.txt for copying permission.
|
||||||
from hbmqtt.mqtt.packet import (
|
from amqtt.mqtt.packet import (
|
||||||
MQTTPacket,
|
MQTTPacket,
|
||||||
MQTTFixedHeader,
|
MQTTFixedHeader,
|
||||||
UNSUBACK,
|
UNSUBACK,
|
||||||
PacketIdVariableHeader,
|
PacketIdVariableHeader,
|
||||||
)
|
)
|
||||||
from hbmqtt.errors import HBMQTTException
|
from amqtt.errors import HBMQTTException
|
||||||
|
|
||||||
|
|
||||||
class UnsubackPacket(MQTTPacket):
|
class UnsubackPacket(MQTTPacket):
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
# See the file license.txt for copying permission.
|
# See the file license.txt for copying permission.
|
||||||
import asyncio
|
import asyncio
|
||||||
|
|
||||||
from hbmqtt.mqtt.packet import (
|
from amqtt.mqtt.packet import (
|
||||||
MQTTPacket,
|
MQTTPacket,
|
||||||
MQTTFixedHeader,
|
MQTTFixedHeader,
|
||||||
UNSUBSCRIBE,
|
UNSUBSCRIBE,
|
||||||
|
|
@ -11,8 +11,8 @@ from hbmqtt.mqtt.packet import (
|
||||||
MQTTPayload,
|
MQTTPayload,
|
||||||
MQTTVariableHeader,
|
MQTTVariableHeader,
|
||||||
)
|
)
|
||||||
from hbmqtt.errors import HBMQTTException, NoDataException
|
from amqtt.errors import HBMQTTException, NoDataException
|
||||||
from hbmqtt.codecs import decode_string, encode_string
|
from amqtt.codecs import decode_string, encode_string
|
||||||
|
|
||||||
|
|
||||||
class UnubscribePayload(MQTTPayload):
|
class UnubscribePayload(MQTTPayload):
|
||||||
|
|
|
||||||
|
|
@ -5,9 +5,9 @@ from datetime import datetime
|
||||||
from collections import deque
|
from collections import deque
|
||||||
import asyncio
|
import asyncio
|
||||||
|
|
||||||
import hbmqtt
|
import amqtt
|
||||||
from hbmqtt.mqtt.packet import PUBLISH
|
from amqtt.mqtt.packet import PUBLISH
|
||||||
from hbmqtt.codecs import int_to_bytes_str
|
from amqtt.codecs import int_to_bytes_str
|
||||||
|
|
||||||
|
|
||||||
DOLLAR_SYS_ROOT = "$SYS/broker/"
|
DOLLAR_SYS_ROOT = "$SYS/broker/"
|
||||||
|
|
@ -61,7 +61,7 @@ class BrokerSysPlugin:
|
||||||
|
|
||||||
async def on_broker_post_start(self, *args, **kwargs):
|
async def on_broker_post_start(self, *args, **kwargs):
|
||||||
self._stats[STAT_START_TIME] = datetime.now()
|
self._stats[STAT_START_TIME] = datetime.now()
|
||||||
version = f"HBMQTT version {hbmqtt.__version__}"
|
version = f"HBMQTT version {amqtt.__version__}"
|
||||||
self.context.retain_message(DOLLAR_SYS_ROOT + "version", version.encode())
|
self.context.retain_message(DOLLAR_SYS_ROOT + "version", version.encode())
|
||||||
|
|
||||||
# Start $SYS topics management
|
# Start $SYS topics management
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,8 @@ import asyncio
|
||||||
from transitions import Machine
|
from transitions import Machine
|
||||||
from asyncio import Queue
|
from asyncio import Queue
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
from hbmqtt.mqtt.publish import PublishPacket
|
from amqtt.mqtt.publish import PublishPacket
|
||||||
from hbmqtt.errors import HBMQTTException
|
from amqtt.errors import HBMQTTException
|
||||||
|
|
||||||
OUTGOING = 0
|
OUTGOING = 0
|
||||||
INCOMING = 1
|
INCOMING = 1
|
||||||
|
|
@ -48,26 +48,26 @@ class ApplicationMessage:
|
||||||
""" Publish message retain flag"""
|
""" Publish message retain flag"""
|
||||||
|
|
||||||
self.publish_packet = None
|
self.publish_packet = None
|
||||||
""" :class:`hbmqtt.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."""
|
""" :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."""
|
||||||
|
|
||||||
self.puback_packet = None
|
self.puback_packet = None
|
||||||
""" :class:`hbmqtt.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."""
|
""" :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."""
|
||||||
|
|
||||||
self.pubrec_packet = None
|
self.pubrec_packet = None
|
||||||
""" :class:`hbmqtt.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."""
|
""" :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."""
|
||||||
|
|
||||||
self.pubrel_packet = None
|
self.pubrel_packet = None
|
||||||
""" :class:`hbmqtt.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."""
|
""" :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."""
|
||||||
|
|
||||||
self.pubcomp_packet = None
|
self.pubcomp_packet = None
|
||||||
""" :class:`hbmqtt.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."""
|
""" :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."""
|
||||||
|
|
||||||
def build_publish_packet(self, dup=False):
|
def build_publish_packet(self, dup=False):
|
||||||
"""
|
"""
|
||||||
Build :class:`hbmqtt.mqtt.publish.PublishPacket` from attributes
|
Build :class:`amqtt.mqtt.publish.PublishPacket` from attributes
|
||||||
|
|
||||||
:param dup: force dup flag
|
:param dup: force dup flag
|
||||||
:return: :class:`hbmqtt.mqtt.publish.PublishPacket` built from ApplicationMessage instance attributes
|
:return: :class:`amqtt.mqtt.publish.PublishPacket` built from ApplicationMessage instance attributes
|
||||||
"""
|
"""
|
||||||
return PublishPacket.build(
|
return PublishPacket.build(
|
||||||
self.topic, self.data, self.packet_id, dup, self.qos, self.retain
|
self.topic, self.data, self.packet_id, dup, self.qos, self.retain
|
||||||
|
|
@ -80,7 +80,7 @@ class ApplicationMessage:
|
||||||
class IncomingApplicationMessage(ApplicationMessage):
|
class IncomingApplicationMessage(ApplicationMessage):
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Incoming :class:`~hbmqtt.session.ApplicationMessage`.
|
Incoming :class:`~amqtt.session.ApplicationMessage`.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
__slots__ = ("direction",)
|
__slots__ = ("direction",)
|
||||||
|
|
@ -93,7 +93,7 @@ class IncomingApplicationMessage(ApplicationMessage):
|
||||||
class OutgoingApplicationMessage(ApplicationMessage):
|
class OutgoingApplicationMessage(ApplicationMessage):
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Outgoing :class:`~hbmqtt.session.ApplicationMessage`.
|
Outgoing :class:`~amqtt.session.ApplicationMessage`.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
__slots__ = ("direction",)
|
__slots__ = ("direction",)
|
||||||
|
|
|
||||||
|
|
@ -4,14 +4,14 @@ import os
|
||||||
import subprocess
|
import subprocess
|
||||||
import warnings
|
import warnings
|
||||||
|
|
||||||
import hbmqtt
|
import amqtt
|
||||||
|
|
||||||
|
|
||||||
def get_version():
|
def get_version():
|
||||||
warnings.warn(
|
warnings.warn(
|
||||||
"hbmqtt.version.get_version() is deprecated, use hbmqtt.__version__ instead"
|
"amqtt.version.get_version() is deprecated, use amqtt.__version__ instead"
|
||||||
)
|
)
|
||||||
return hbmqtt.__version__
|
return amqtt.__version__
|
||||||
|
|
||||||
|
|
||||||
def get_git_changeset():
|
def get_git_changeset():
|
||||||
|
|
|
||||||
Ładowanie…
Reference in New Issue