本文整理汇总了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)
示例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)