示例#1
0
    virtual uint64_t
    expressInterest
      (const Interest& interest, const OnData& onData,
       const OnTimeout& onTimeout, const OnNetworkNack& onNetworkNack,
       WireFormat& wireFormat = *WireFormat::getDefaultWireFormat())
    {
      if (interest.getLink()->getDelegations().size() != 3)
        throw runtime_error
          ("TestFace::expressInterest: The Interest link does not the expected number of delegates");

      if (interest.matchesName(contentData_->getName())) {
        *contentCount_ = 1;
        onData(ptr_lib::make_shared<Interest>(interest), contentData_);
      }
      else if (interest.matchesName(cKeyData_->getName())) {
        *cKeyCount_ = 1;
        onData(ptr_lib::make_shared<Interest>(interest), cKeyData_);
      }
      else if (interest.matchesName(dKeyData_->getName())) {
        *dKeyCount_ = 1;
        onData(ptr_lib::make_shared<Interest>(interest), dKeyData_);
      }
      else
        onTimeout(ptr_lib::make_shared<Interest>(interest));

      return 0;
    }
示例#2
0
    virtual uint64_t
    expressInterest
      (const Interest& interest, const OnData& onData,
       const OnTimeout& onTimeout, const OnNetworkNack& onNetworkNack,
       WireFormat& wireFormat = *WireFormat::getDefaultWireFormat())
    {
      if (expectedInterest_ != interest.getName())
        throw runtime_error("TestFace::expressInterest: Not the expectedInterest_");

      bool gotInterestName = false;
      Name interestName;
      for (size_t i = 0; i < 3; ++i) {
        interestName = Name(interest.getName());
        if (i == 0)
          interestName.append(timeMarkerFirstHop_);
        else if (i == 1)
          interestName.append(timeMarkerSecondHop_);
        else if (i == 2)
          interestName.append(timeMarkerThirdHop_);

        // matchesName will check the Exclude.
        if (interest.matchesName(interestName)) {
          gotInterestName = true;
          ++(*requestCount_);
          break;
        }
      }

      if (gotInterestName)
        onData(ptr_lib::make_shared<Interest>(interest),
               parent_->encryptionKeys[interestName]);

      return 0;
    }
示例#3
0
    virtual uint64_t
    expressInterest
      (const Interest& interest, const OnData& onData,
       const OnTimeout& onTimeout, const OnNetworkNack& onNetworkNack,
       WireFormat& wireFormat = *WireFormat::getDefaultWireFormat())
    {
      if (interest.matchesName(contentData_->getName())) {
        *contentCount_ = 1;
        onData(ptr_lib::make_shared<Interest>(interest), contentData_);
      }
      else if (interest.matchesName(cKeyData_->getName())) {
        *cKeyCount_ = 1;
        onData(ptr_lib::make_shared<Interest>(interest), cKeyData_);
      }
      else if (interest.matchesName(dKeyData_->getName())) {
        *dKeyCount_ = 1;
        onData(ptr_lib::make_shared<Interest>(interest), dKeyData_);
      }
      else
        onTimeout(ptr_lib::make_shared<Interest>(interest));

      return 0;
    }