Exemplo n.º 1
0
    void
    fetchInformation()
    {
      if (!m_versionRetrieval && !m_faceStatusRetrieval && !m_fibEnumerationRetrieval)
        {
          setVersionRetrieval();
          setFaceStatusRetrieval();
          setFibEnumerationRetrieval();
        }
      if (m_versionRetrieval)
        {
          fetchVersionInformation();
        }
      if (m_faceStatusRetrieval)
        {
          fetchFaceStatusInformation();
        }
      if (m_fibEnumerationRetrieval)
        {
          fetchFibEnumerationInformation();
        }

      try {
        m_face.processEvents();
      }
      catch(std::exception &e) {
        std::cout << "ERROR: " << e.what() << std::endl;
      }
    }
    void
    onInterest(const ndn::Name& name, const ndn::Interest& interest)
    {
        ndn::Name interestName(interest.getName());

        if(DEBUG)
            std::cout << "received interest: " << interest.getName() << std::endl;

        //run scripts if requested by server
        ndn::Name cmpName(getFilter()+SCRIPT_SUFFIX);
        int num_components = cmpName.size();
        if(cmpName.isPrefixOf(interestName))
        {
            int numberOfComponents = interestName.size();
            for(int i = num_components; i < numberOfComponents; ++i)
            {
                m_scriptsList.push_front(interestName[i].toUri());
            }
            runScripts(interestName);
        }
        else
        {
            int numberOfComponents = interestName.size();
            if(!m_remoteLinks.empty())
            {
                std::cerr << "remote links list is not empty - check for a missing reports!!" << std::endl;
                m_remoteLinks.clear();
            }
            for(int i = name.size(); i < numberOfComponents; ++i)
            {
                m_remoteLinks.insert(interestName[i].toUri());
            }

            // ask for local status
            fetchFaceStatusInformation(interestName);
        }
    }