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


Python Protocol.connectionLost方法代码示例

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


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

示例1: connectionLost

# 需要导入模块: from twisted.internet.protocol import Protocol [as 别名]
# 或者: from twisted.internet.protocol.Protocol import connectionLost [as 别名]
 def connectionLost(self, reason):
     Protocol.connectionLost(self, reason)
     self.started = False
     self.factory.number_of_connections -= 1
     self.player = None
     print "lost"
     print "Current number of connections:", self.factory.number_of_connections
开发者ID:asafebgi,项目名称:adilate-flash-gui,代码行数:9,代码来源:player_protocol.py

示例2: connectionLost

# 需要导入模块: from twisted.internet.protocol import Protocol [as 别名]
# 或者: from twisted.internet.protocol.Protocol import connectionLost [as 别名]
 def connectionLost(self, reason):
     # remove from channel and disconnect, reset state machine
     if self in self.factory.channels[self.channel]: 
         self.factory.channels[self.channel].remove(self)
     if self.factory.channels[self.channel].count <= 0:
         del self.factory.channels[self.channel]
     self.curState=ProtocolState.CO_NO
     self.factory.notifyObservers("A dude left the channel", self.channel)
     Protocol.connectionLost(self, reason=reason)
开发者ID:nihathrael,项目名称:rateit,代码行数:11,代码来源:twistedserver.py

示例3: connectionLost

# 需要导入模块: from twisted.internet.protocol import Protocol [as 别名]
# 或者: from twisted.internet.protocol.Protocol import connectionLost [as 别名]
 def connectionLost(self, reason = connectionDone):
     log.info('SyncAnyProtocol::connectionLost')
     
     self.started = False
     Protocol.connectionLost(self, reason)
     
     #self.factory.clients.remove(self)
     if not self.user is None:
         self.factory.clients.removeClient(self)
开发者ID:edceza,项目名称:syncanything,代码行数:11,代码来源:sync_any_server.py

示例4: connectionLost

# 需要导入模块: from twisted.internet.protocol import Protocol [as 别名]
# 或者: from twisted.internet.protocol.Protocol import connectionLost [as 别名]
 def connectionLost(self, reason):
     #print "CONNECTIONLOST"
     #MultiBufferer.connectionLost(self, reason)
     # XXX When we call MultiBufferer.connectionLost, we get
     # unhandled errors (something isn't adding an Errback
     # to the deferred which eventually gets GC'd, but I'm
     # not *too* worried because it *does* get GC'd).
     # Do check that the things which yield on read() on
     # the multibufferer get correctly GC'd though.
     Protocol.connectionLost(self, reason)
开发者ID:Fishbubble,项目名称:txMySQL,代码行数:12,代码来源:protocol.py

示例5: connectionLost

# 需要导入模块: from twisted.internet.protocol import Protocol [as 别名]
# 或者: from twisted.internet.protocol.Protocol import connectionLost [as 别名]
 def connectionLost(self, reason=ResponseDone):
     """
     overload Protocol.connectionLost to handle disconnect
     """
     Protocol.connectionLost(self, reason)
     if reason.check(ResponseDone):
         self._deferred.callback(True)
     else:
         log.err("ResponseProducerProtocol connection lost %s" % (reason, ),
                 logLevel=logging.ERROR)
         self._deferred.errback(reason)
开发者ID:SpiderOak,项目名称:twisted_client_for_nimbusio,代码行数:13,代码来源:response_producer_protocol.py

示例6: connectionLost

# 需要导入模块: from twisted.internet.protocol import Protocol [as 别名]
# 或者: from twisted.internet.protocol.Protocol import connectionLost [as 别名]
 def connectionLost(self, reason=connectionDone):
     """Abort any outstanding requests when we lose our connection."""
     Protocol.connectionLost(self, reason)
     requests = self.requests.values()
     for request in requests:
         request.stopProducing()
         if request.started:
             request.cancel()
         try:
             # also removes from self.requests
             request.error(reason)
         except defer.AlreadyCalledError:
             # cancel may already have error-ed the request
             continue
开发者ID:thnguyn2,项目名称:ECE_527_MP,代码行数:16,代码来源:request.py

示例7: reconnector

# 需要导入模块: from twisted.internet.protocol import Protocol [as 别名]
# 或者: from twisted.internet.protocol.Protocol import connectionLost [as 别名]
 def reconnector(self, onion):
     protocol = Protocol()
     protocol.onion = onion
     protocol.connectionLost = lambda failure: self.handleLostConnection(failure, onion)
     tor_endpoint = clientFromString(self.reactor, "tor:%s.onion:8060" % onion)
     self.onion_pending_map[onion] = connectProtocol(tor_endpoint, protocol)
     self.onion_pending_map[onion].addCallback(lambda protocol: self.connection_ready(onion, protocol))
     self.onion_pending_map[onion].addErrback(lambda failure: self.connectFail(failure, onion))
开发者ID:hotelzululima,项目名称:onionvpn,代码行数:10,代码来源:ipv6_onion_consumer.py

示例8: connectionLost

# 需要导入模块: from twisted.internet.protocol import Protocol [as 别名]
# 或者: from twisted.internet.protocol.Protocol import connectionLost [as 别名]
 def connectionLost(self, reason=connectionDone):
     #logger.debug("connectionLost(): %s", str(reason))
     logger.debug("connectionLost(): %s port %s to %s:%s %s%s",
                  self.factory.name,
                  self.factory.local_port,
                  self.factory.host, self.factory.port,
                  self.protocol_name,
                  "" if type(reason) == ConnectionDone else ": %s" % str(reason))
     return Protocol.connectionLost(self, reason)
开发者ID:da4089,项目名称:robot-nps,代码行数:11,代码来源:base.py

示例9: connectionLost

# 需要导入模块: from twisted.internet.protocol import Protocol [as 别名]
# 或者: from twisted.internet.protocol.Protocol import connectionLost [as 别名]
 def connectionLost(self, reason):
     """When TCP connection is lost, remove shutdown handler
     """
     if reason.type == ConnectionLost:
         msg = 'Disconnected'
     else:
         msg = 'Disconnected: %s' % reason.getErrorMessage()
     self.log.debug(msg)
         
     #Remove connect timeout if set
     if self.connectTimeoutDelayedCall is not None:
         self.log.debug('Cancelling connect timeout after TCP connection was lost')
         self.connectTimeoutDelayedCall.cancel()
         self.connectTimeoutDelayedCall = None
     
     #Callback for failed connect
     if self.connectedDeferred:
         if self.connectError:
             self.log.debug('Calling connectedDeferred errback: %s' % self.connectError)
             self.connectedDeferred.errback(self.connectError)
             self.connectError = None
         else:
             self.log.error('Connection lost with outstanding connectedDeferred')
             error = StompError('Unexpected connection loss')
             self.log.debug('Calling connectedDeferred errback: %s' % error)
             self.connectedDeferred.errback(error)                
         self.connectedDeferred = None
     
     #Callback for disconnect
     if self.disconnectedDeferred:
         if self.disconnectError:
             #self.log.debug('Calling disconnectedDeferred errback: %s' % self.disconnectError)
             self.disconnectedDeferred.errback(self.disconnectError)
             self.disconnectError = None
         else:
             #self.log.debug('Calling disconnectedDeferred callback')
             self.disconnectedDeferred.callback(self)
         self.disconnectedDeferred = None
         
     Protocol.connectionLost(self, reason)
开发者ID:mozes,项目名称:stompest,代码行数:42,代码来源:async.py

示例10: connectionLost

# 需要导入模块: from twisted.internet.protocol import Protocol [as 别名]
# 或者: from twisted.internet.protocol.Protocol import connectionLost [as 别名]
    def connectionLost(self, reason=twistedError.ConnectionDone):

        if self.role == Command.BaseCommand.PV_ROLE_HUMAN:
            InternalMessage.UnregistFilter(InternalMessage.TTYPE_HUMAN, self.client_id)
            InternalMessage.NotifyTerminalStatus(
                InternalMessage.TTYPE_HUMAN, self.client_id, id(self.transport), InternalMessage.OPER_OFFLINE, "n"
            )
        elif self.role == Command.BaseCommand.PV_ROLE_SUPERBOX:
            InternalMessage.UnregistFilter(InternalMessage.TTYPE_GATEWAY, self.superbox_id)
            InternalMessage.NotifyTerminalStatus(
                InternalMessage.TTYPE_GATEWAY, self.superbox_id, 0, InternalMessage.OPER_OFFLINE
            )

        try:
            self.timer.cancel()
        except Exception:
            pass
        # print "connection lost:",id(self.transport),reason
        self.releaseFromDict()

        with self.factory.lockPendingCmd:
            SBProtocol.connection_count = SBProtocol.connection_count - 1
        Protocol.connectionLost(self, reason=reason)
开发者ID:skycucumber,项目名称:Messaging-Gateway,代码行数:25,代码来源:ProtocolReactor.py

示例11: connectionLost

# 需要导入模块: from twisted.internet.protocol import Protocol [as 别名]
# 或者: from twisted.internet.protocol.Protocol import connectionLost [as 别名]
 def connectionLost(self, reason):
     Protocol.connectionLost(self, reason)
     self.log.debug("Connection lost.")
     self.engine.unbind()
开发者ID:NurKaynar,项目名称:hacklab,代码行数:6,代码来源:TwistedServerExample.py

示例12: connectionLost

# 需要导入模块: from twisted.internet.protocol import Protocol [as 别名]
# 或者: from twisted.internet.protocol.Protocol import connectionLost [as 别名]
 def connectionLost(self, reason=error.ConnectionDone):
     Protocol.connectionLost(self, reason=reason)
开发者ID:DBrianKimmel,项目名称:PyHouse,代码行数:4,代码来源:samsung.py

示例13: connectionLost

# 需要导入模块: from twisted.internet.protocol import Protocol [as 别名]
# 或者: from twisted.internet.protocol.Protocol import connectionLost [as 别名]
 def connectionLost(self, reason):
     Protocol.connectionLost(self, reason=reason)
     self.curState=ProtocolState.CO_NO
开发者ID:nihathrael,项目名称:rateit,代码行数:5,代码来源:twistedclient.py

示例14: connectionLost

# 需要导入模块: from twisted.internet.protocol import Protocol [as 别名]
# 或者: from twisted.internet.protocol.Protocol import connectionLost [as 别名]
 def connectionLost(self, reason=ConnectionDone):
     Protocol.connectionLost(self, reason=reason)
     LOG.warn('Lost connection.\n\tReason:{}'.format(reason))
开发者ID:DBrianKimmel,项目名称:PyHouse,代码行数:5,代码来源:onkyo.py

示例15: connectionLost

# 需要导入模块: from twisted.internet.protocol import Protocol [as 别名]
# 或者: from twisted.internet.protocol.Protocol import connectionLost [as 别名]
    def connectionLost(self, reason):
        Protocol.connectionLost(self, reason)

        self.factory.number_of_connections -= 1
开发者ID:84322146,项目名称:pyamf,代码行数:6,代码来源:server.py


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