def __init__(self):
"""
Start the client, subscribe to "test" and start the loop
"""
super(MQSUB, self).__init__()
# super().on_connect = self.on_connect
# super().on_message = self.on_message
self.start = 0
self.end = 0
self.message_count = 0
# determine current IP address of the local computer
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
# use the google dns
s.connect(('8.8.8.8', 0))
self.ip_address = s.getsockname()[0]
self.connect(self.ip_address, 1883, 60)
self.subscribe("test", 0)
self.loop_forever()
评论列表
文章目录