Пример #1
0
  def handleFrame(self, frame):
    ackFrame = AckFrame()
    ackFrame.fromFrame(frame)

    if ackFrame.isData()
      ackFrame.confirmation()
      self._frameLayer.sendFrame(confirmationFrame.type(), 
                                 self._fromId, 
                                 confirmationFrame.toId(), 
                                 confirmationFrame.bytes())
    elif self.isConfirmation()
      uniqueID = ackFrame.uniqueID()
      toId = ackFrame.fromId()

      self._deferreds[toId][uniqueID].resolve(time.time())
      self._deferreds[toId][uniqueID] = None
Пример #2
0
  def sendFrame(self, toId, message):
    ackFrame = AckFrame()

    ackFrame.setUniqueID(self._UIDProvider.UIDFor(toId))
    ackFrame.toSend(self._fromId, toId, message)

    self._frameLayer.sendFrame(ackFrame.type(),
                               ackFrame.fromId(),
                               ackFrame.toId()
                               ackFrame.bytes())

    if self._deferreds.get(toId) == None:
      self._deferreds[toId] = {}

    self._deferreds[toId][ackFrame.uniqueID()] = AckDeferred(ackFrame)
    return self._deferreds[toId][ackFrame.uniqueID()].promise()