当前位置: 首页>>代码示例>>Python>>正文


Python Factory.onDisconnect方法代码示例

本文整理汇总了Python中twisted.internet.protocol.Factory.onDisconnect方法的典型用法代码示例。如果您正苦于以下问题:Python Factory.onDisconnect方法的具体用法?Python Factory.onDisconnect怎么用?Python Factory.onDisconnect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在twisted.internet.protocol.Factory的用法示例。


在下文中一共展示了Factory.onDisconnect方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _connectToFaultManager

# 需要导入模块: from twisted.internet.protocol import Factory [as 别名]
# 或者: from twisted.internet.protocol.Factory import onDisconnect [as 别名]
 def _connectToFaultManager(self):
   factory = Factory()
   factory.protocol = ServerProtocol
   factory.messageProcessor = self
   factory.onConnect = self.connectedToFaultManager
   factory.onDisconnect = self.disconnectedFromFaultManager
   point = TCP4ClientEndpoint(reactor, self._faultManagerAddress, self._faultManagerPort)
   d = point.connect(factory)
   d.addErrback(self._onListenError)
开发者ID:jonathonw,项目名称:FailoverHomework,代码行数:11,代码来源:Server.py

示例2: _listen

# 需要导入模块: from twisted.internet.protocol import Factory [as 别名]
# 或者: from twisted.internet.protocol.Factory import onDisconnect [as 别名]
 def _listen(self):
   factory = Factory()
   factory.protocol = ServerProtocol
   factory.messageProcessor = self
   factory.onConnect = self.clientConnected
   factory.onDisconnect = self.clientDisconnected
   point = TCP4ServerEndpoint(reactor, self._localPort)
   d = point.listen(factory)
   d.addErrback(self._onListenError)
开发者ID:jonathonw,项目名称:FailoverHomework,代码行数:11,代码来源:Server.py

示例3: _backupState

# 需要导入模块: from twisted.internet.protocol import Factory [as 别名]
# 或者: from twisted.internet.protocol.Factory import onDisconnect [as 别名]
 def _backupState(self):
   for (address, port) in self._replicaList:
     if not (address == self._localAddress and port == self._localPort): #don't connect to ourselves
       factory = Factory()
       factory.protocol = ServerProtocol
       factory.messageProcessor = self
       factory.onConnect = self.connectedToBackup
       factory.onDisconnect = None
       point = TCP4ClientEndpoint(reactor, address, port, timeout=2)
       d = point.connect(factory)
开发者ID:jonathonw,项目名称:FailoverHomework,代码行数:12,代码来源:Server.py

示例4: _connectToReplica

# 需要导入模块: from twisted.internet.protocol import Factory [as 别名]
# 或者: from twisted.internet.protocol.Factory import onDisconnect [as 别名]
 def _connectToReplica(self):
   if self._replicaIndexToAttempt < len(self._replicaList):
     
     factory = Factory()
     factory.protocol = ClientProtocol
     factory.messageProcessor = self
     factory.onConnect = self.connectedToServerReplica
     factory.onDisconnect = self.disconnectedFromServerReplica
     
     (replicaAddress, replicaPort) = self._replicaList[self._replicaIndexToAttempt]
     print "Connecting to primary replica", replicaAddress + ":" + str(replicaPort)
     point = TCP4ClientEndpoint(reactor, replicaAddress, replicaPort)
     d = point.connect(factory)
     d.addErrback(self._onServerReplicaConnectError)
     self._replicaIndexToAttempt += 1
   else:
     #if we run out of replicas, send OperationComplete with result set to None
     #so that performOperation will raise an exception
     self._operationCompleteCondition.acquire()
     self._operationResult = None
     self._operationCompleteCondition.notifyAll()
     self._operationCompleteCondition.release()
开发者ID:jonathonw,项目名称:FailoverHomework,代码行数:24,代码来源:Client.py


注:本文中的twisted.internet.protocol.Factory.onDisconnect方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。