Errors when running the script...
Marmachine opened this issue · 0 comments
Marmachine commented
class Client should be updated!
class Client:
def on_message(self, ws, message):
x = datetime.datetime.now()
print("msg ", x.strftime("%H:%M:%S,%f"))
mqtt_parse(message)
print(message)
sys.stdout.flush()
def on_error(self, ws, error):
x = datetime.datetime.now()
print("error ", x.strftime("%H:%M:%S,%f"))
print(error)
def on_close(self, ws, close_status_code, close_msg):
self.live = False
x = datetime.datetime.now()
print("closed ", x.strftime("%H:%M:%S,%f"))
print("### closed ###")
if close_status_code:
print("status code: "+close_status_code)
if close_msg:
print("status message: "+close_msg)
sys.exit(0)
def on_open(self, ws):
x = datetime.datetime.now()
print("connected ", x.strftime("%H:%M:%S,%f"))
print("### connected ###")
self.live = True
def run(*args):
while self.live:
time.sleep(1)
Thread(target=run).start()