pushover_open_client.py 文件源码

python
阅读 18 收藏 0 点赞 0 评论 0

项目:py-pushover-open-client 作者: aeirsoul 项目源码 文件源码
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.")
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号