def connect(self, callback, traceRoute):
"""Connects the client to the websocket"""
if(not self.isConnected()):
if(traceRoute):
#Enables tracing of connection
self.trace = True
websocket.enableTrace(True)
#Set callback for received messages to go to
self.callback = callback
#Have to put this in here, otherwise respawned dies for some reason
self.ws = websocket.WebSocketApp(WEBSOCKET_URL,
on_message = self.onRecieve,
on_error = self.onError,
on_close = self.onClose)
self.ws.on_open = self.onOpen
#Start the actual connection
self.mainThread = threading.Thread(target = self.ws.run_forever, args=())
self.mainThread.start()
else:
print ("Attempting to connect but already connected.")
pushover_open_client.py 文件源码
python
阅读 18
收藏 0
点赞 0
评论 0
评论列表
文章目录