当前位置: 首页>>代码示例>>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;未经允许,请勿转载。