Exemple #1
0
void
Nfdc::ribRegisterPrefix()
{
  m_name = m_commandLineArguments[0];
  const std::string& faceName = m_commandLineArguments[1];

  FaceIdFetcher::start(m_face, m_controller, faceName, true,
                       [this] (const uint32_t faceId) {
                         ControlParameters parameters;
                         parameters
                           .setName(m_name)
                           .setCost(m_cost)
                           .setFlags(m_flags)
                           .setOrigin(m_origin)
                           .setFaceId(faceId);

                         if (m_expires != DEFAULT_EXPIRATION_PERIOD)
                           parameters.setExpirationPeriod(m_expires);

                         m_controller
                           .start<RibRegisterCommand>(parameters,
                                                      bind(&Nfdc::onSuccess, this, _1,
                                                           "Successful in name registration"),
                                                      bind(&Nfdc::onError, this, _1, _2,
                                                           "Failed in name registration"));
                       },
                       bind(&Nfdc::onObtainFaceIdFailure, this, _1));
}
Exemple #2
0
void
Nfdc::ribRegisterPrefix()
{
  m_name = m_commandLineArguments[0];
  ControlParameters parameters;
  parameters
    .setName(m_name)
    .setCost(m_cost)
    .setFlags(m_flags)
    .setOrigin(m_origin);

  if (m_expires != DEFAULT_EXPIRATION_PERIOD)
    parameters.setExpirationPeriod(m_expires);

  if (!isValidUri(m_commandLineArguments[1])) {
    try { //So the uri is not valid, may be a faceId is provided.
      m_faceId = boost::lexical_cast<int>(m_commandLineArguments[1]);
    }
    catch (const std::exception& e) {
      std::cerr << "No valid faceUri or faceId is provided"<< std::endl;
      return;
    }
    parameters.setFaceId(m_faceId);
    ribRegisterPrefix(parameters);
  }
  else {
    ControlParameters faceParameters;
    faceParameters.setUri(m_commandLineArguments[1]);

    m_controller.start<FaceCreateCommand>(faceParameters,
                                          bind(&Nfdc::ribRegisterPrefix, this, _1),
                                          bind(&Nfdc::onError, this, _1, _2,
                                               "Face creation failed"));
  }
}
 virtual void
 applyDefaultsToRequest(ControlParameters& parameters) const
 {
   if (!parameters.hasFaceId()) {
     parameters.setFaceId(0);
   }
   if (!parameters.hasOrigin()) {
     parameters.setOrigin(ROUTE_ORIGIN_APP);
   }
   if (!parameters.hasCost()) {
     parameters.setCost(0);
   }
   if (!parameters.hasFlags()) {
     parameters.setFlags(ROUTE_FLAG_CHILD_INHERIT);
   }
   if (!parameters.hasExpirationPeriod()) {
     if (parameters.getFaceId() == 0) {
       parameters.setExpirationPeriod(time::milliseconds::max());
     }
     else {
       parameters.setExpirationPeriod(time::hours(1));
     }
   }
 }
Exemple #4
0
void
Nfdc::ribRegisterPrefix(const ControlParameters& faceCreateResult)
{
  ControlParameters ribParameters;
  ribParameters
    .setName(m_name)
    .setCost(m_cost)
    .setFlags(m_flags)
    .setOrigin(m_origin)
    .setFaceId(faceCreateResult.getFaceId());

  if (m_expires != DEFAULT_EXPIRATION_PERIOD)
    ribParameters.setExpirationPeriod(m_expires);

  m_controller.start<RibRegisterCommand>(ribParameters,
                                         bind(&Nfdc::onSuccess, this, _1,
                                                "Successful in name registration"),
                                         bind(&Nfdc::onError, this, _1, _2,
                                                "Failed in name registration"));
}