Example #1
0
 def __init__(self, connectionPool, timeout=10):
     """
     We have access to the connection pool so we can store connections
     there after they've been successfully made.
     """
     MsgPackProtocol.__init__(self, timeout)
     self.connectionPool = connectionPool
     self.log = Logger(system=self)
     self.storage = self.connectionPool.storage
     self.peersKeyId = None
Example #2
0
 def connectionLost(self, reason):
     keyId = self.getPeersKeyId()
     self.log.warning("Connection to %s lost: %s" % (keyId, str(reason)))
     self.connectionPool.forgetConnection(keyId)
     MsgPackProtocol.connectionLost(self, reason)
Example #3
0
 def dataReceived(self, data):
     self.connectionPool.saveConnection(self, self.getPeersKeyId())
     self.log.debug("received data from %s: %s" % (self.getPeersKeyId(), data))
     MsgPackProtocol.dataReceived(self, data)