kopia lustrzana https://github.com/Yakifo/amqtt
Add Ping req/resp packet
rodzic
5d147415f1
commit
ad74ad6a71
|
@ -0,0 +1,20 @@
|
||||||
|
# Copyright (c) 2015 Nicolas JOUANIN
|
||||||
|
#
|
||||||
|
# See the file license.txt for copying permission.
|
||||||
|
from hbmqtt.mqtt.packet import MQTTPacket, MQTTFixedHeader, PacketType, MQTTVariableHeader, MQTTPayload
|
||||||
|
from hbmqtt.errors import HBMQTTException
|
||||||
|
|
||||||
|
class PingReqPacket(MQTTPacket):
|
||||||
|
VARIABLE_HEADER = None
|
||||||
|
PAYLOAD = None
|
||||||
|
|
||||||
|
def __init__(self, fixed: MQTTFixedHeader=None):
|
||||||
|
if fixed is None:
|
||||||
|
header = MQTTFixedHeader(PacketType.PINGREQ, 0x00)
|
||||||
|
else:
|
||||||
|
if fixed.packet_type is not PacketType.DISCONNECT:
|
||||||
|
raise HBMQTTException("Invalid fixed packet type %s for PingReqPacket init" % fixed.packet_type)
|
||||||
|
header = fixed
|
||||||
|
super().__init__(header)
|
||||||
|
self.variable_header = None
|
||||||
|
self.payload = None
|
|
@ -0,0 +1,20 @@
|
||||||
|
# Copyright (c) 2015 Nicolas JOUANIN
|
||||||
|
#
|
||||||
|
# See the file license.txt for copying permission.
|
||||||
|
from hbmqtt.mqtt.packet import MQTTPacket, MQTTFixedHeader, PacketType, MQTTVariableHeader, MQTTPayload
|
||||||
|
from hbmqtt.errors import HBMQTTException
|
||||||
|
|
||||||
|
class PingRespPacket(MQTTPacket):
|
||||||
|
VARIABLE_HEADER = None
|
||||||
|
PAYLOAD = None
|
||||||
|
|
||||||
|
def __init__(self, fixed: MQTTFixedHeader=None):
|
||||||
|
if fixed is None:
|
||||||
|
header = MQTTFixedHeader(PacketType.PINGREQ, 0x00)
|
||||||
|
else:
|
||||||
|
if fixed.packet_type is not PacketType.DISCONNECT:
|
||||||
|
raise HBMQTTException("Invalid fixed packet type %s for PingRespPacket init" % fixed.packet_type)
|
||||||
|
header = fixed
|
||||||
|
super().__init__(header)
|
||||||
|
self.variable_header = None
|
||||||
|
self.payload = None
|
Ładowanie…
Reference in New Issue