當前位置: 首頁>>代碼示例>>Python>>正文


Python YowNetworkLayer.EVENT_STATE_DISCONNECTED屬性代碼示例

本文整理匯總了Python中yowsup.layers.network.YowNetworkLayer.EVENT_STATE_DISCONNECTED屬性的典型用法代碼示例。如果您正苦於以下問題:Python YowNetworkLayer.EVENT_STATE_DISCONNECTED屬性的具體用法?Python YowNetworkLayer.EVENT_STATE_DISCONNECTED怎麽用?Python YowNetworkLayer.EVENT_STATE_DISCONNECTED使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在yowsup.layers.network.YowNetworkLayer的用法示例。


在下文中一共展示了YowNetworkLayer.EVENT_STATE_DISCONNECTED屬性的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: onEvent

# 需要導入模塊: from yowsup.layers.network import YowNetworkLayer [as 別名]
# 或者: from yowsup.layers.network.YowNetworkLayer import EVENT_STATE_DISCONNECTED [as 別名]
def onEvent(self, layerEvent):
        credentials=self.getProp(YowAuthenticationProtocolLayer.PROP_CREDENTIALS)
        id=str(credentials[0])
        logger.info(id +': '+ layerEvent.getName())
        if layerEvent.getName() == YowNetworkLayer.EVENT_STATE_DISCONNECTED:
            logger.warning("Id: %s, Disconnected: %s" % (id,layerEvent.getArg("reason")))
            if layerEvent.getArg("reason") in ('Connection Closed','Ping Timeout'):
                time.sleep(20)
                logger.info("Id: %s, Issueing EVENT_STATE_CONNECT" % id)
                self.getStack().broadcastEvent(YowLayerEvent(YowNetworkLayer.EVENT_STATE_CONNECT))
            else:
                app=self.getProp('flaskApp')
                if hasattr(app,'layers') and 'credentials'  in app.layers:
                    del app.layers[credentials]
        elif layerEvent.getName() == YowNetworkLayer.EVENT_STATE_CONNECTED:
            logger.info("Id: %s Connected"% id) 
開發者ID:johntheknife,項目名稱:yowsuphttpinterface,代碼行數:18,代碼來源:layer.py

示例2: onEvent

# 需要導入模塊: from yowsup.layers.network import YowNetworkLayer [as 別名]
# 或者: from yowsup.layers.network.YowNetworkLayer import EVENT_STATE_DISCONNECTED [as 別名]
def onEvent(self, layerEvent):
        if layerEvent.getName() == self.__class__.EVENT_START:
            self.startInput()
            return True
        elif layerEvent.getName() == self.__class__.EVENT_SENDANDEXIT:
            credentials = layerEvent.getArg("credentials")
            target = layerEvent.getArg("target")
            message = layerEvent.getArg("message")
            self.sendMessageAndDisconnect(credentials, target, message)
            return True
        elif layerEvent.getName() == YowNetworkLayer.EVENT_STATE_DISCONNECTED:
            self.output("Disconnected: %s" % layerEvent.getArg("reason"))
            if self.disconnectAction == self.__class__.DISCONNECT_ACTION_PROMPT:
                self.connected = False
                self.notifyInputThread()
            else:
                os._exit(os.EX_OK) 
開發者ID:Gab0,項目名稱:dZAP,代碼行數:19,代碼來源:layer.py


注:本文中的yowsup.layers.network.YowNetworkLayer.EVENT_STATE_DISCONNECTED屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。