示例#1
0
文件: node.cpp 项目: susmit85/ndn-cpp
void
Node::expressInterestHelper
  (uint64_t pendingInterestId,
   const ptr_lib::shared_ptr<const Interest>& interestCopy,
   const OnData& onData, const OnTimeout& onTimeout, WireFormat* wireFormat,
   Face* face)
{
  ptr_lib::shared_ptr<PendingInterest> pendingInterest(new PendingInterest
    (pendingInterestId, interestCopy, onData, onTimeout));
  pendingInterestTable_.push_back(pendingInterest);
  if (interestCopy->getInterestLifetimeMilliseconds() >= 0.0)
    // Set up the timeout.
    face->callLater
      (interestCopy->getInterestLifetimeMilliseconds(),
       bind(&Node::processInterestTimeout, this, pendingInterest));

  // Special case: For timeoutPrefix_ we don't actually send the interest.
  if (!timeoutPrefix_.match(interestCopy->getName())) {
    Blob encoding = interestCopy->wireEncode(*wireFormat);
    if (encoding.size() > getMaxNdnPacketSize())
      throw runtime_error
        ("The encoded interest size exceeds the maximum limit getMaxNdnPacketSize()");
    transport_->send(*encoding);
  }
}