Exemplo n.º 1
0
 def connectionLost(self, reason):
     """
     Once the connection is lost, put back the client ID into the pool,
     and remove the client from all the channels it has signed on to.
     """
     BaseProtocol.connectionLost(self, reason)
     factory = self.factory
     if self._timeoutCall is not None and self._timeoutCall.active():
         self._timeoutCall.cancel()
         self._timeoutCall = None
     if self._currentPing is not None and self._currentPing.active():
         self._currentPing.cancel()
         self._currentPing = None
     
     for channel in self.channels.values():
         self.leaveChannel(channel)
     if self.isAccepted:
         factory.userPool.putBack(self.id)
         del self.factory.connections[self]