kopia lustrzana https://github.com/Yakifo/amqtt
commit
059baa78bf
|
@ -7,6 +7,7 @@ from hbmqtt.codecs import bytes_to_int, decode_data_with_length, decode_string,
|
||||||
from hbmqtt.mqtt.packet import MQTTPacket, MQTTFixedHeader, CONNECT, MQTTVariableHeader, MQTTPayload
|
from hbmqtt.mqtt.packet import MQTTPacket, MQTTFixedHeader, CONNECT, MQTTVariableHeader, MQTTPayload
|
||||||
from hbmqtt.errors import HBMQTTException, NoDataException
|
from hbmqtt.errors import HBMQTTException, NoDataException
|
||||||
from hbmqtt.adapters import ReaderAdapter
|
from hbmqtt.adapters import ReaderAdapter
|
||||||
|
from hbmqtt.utils import gen_client_id
|
||||||
|
|
||||||
|
|
||||||
class ConnectVariableHeader(MQTTVariableHeader):
|
class ConnectVariableHeader(MQTTVariableHeader):
|
||||||
|
@ -161,6 +162,9 @@ class ConnectPayload(MQTTPayload):
|
||||||
except NoDataException:
|
except NoDataException:
|
||||||
payload.client_id = None
|
payload.client_id = None
|
||||||
|
|
||||||
|
if (payload.client_id is None or payload.client_id == ""):
|
||||||
|
payload.client_id=gen_client_id();
|
||||||
|
|
||||||
# Read will topic, username and password
|
# Read will topic, username and password
|
||||||
if variable_header.will_flag:
|
if variable_header.will_flag:
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -103,7 +103,7 @@ class MQTTClientTest(unittest.TestCase):
|
||||||
broker = Broker(broker_config, plugin_namespace="hbmqtt.test.plugins")
|
broker = Broker(broker_config, plugin_namespace="hbmqtt.test.plugins")
|
||||||
yield from broker.start()
|
yield from broker.start()
|
||||||
client = MQTTClient()
|
client = MQTTClient()
|
||||||
yield from client.connect('ws://localhost:8081/')
|
yield from client.connect('ws://localhost:8080/')
|
||||||
self.assertIsNotNone(client.session)
|
self.assertIsNotNone(client.session)
|
||||||
yield from client.disconnect()
|
yield from client.disconnect()
|
||||||
yield from broker.shutdown()
|
yield from broker.shutdown()
|
||||||
|
|
Ładowanie…
Reference in New Issue