本文整理匯總了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)