当前位置: 首页>>代码示例>>C++>>正文


C++ ControlParameters::setForwardingFlags方法代码示例

本文整理汇总了C++中ControlParameters::setForwardingFlags方法的典型用法代码示例。如果您正苦于以下问题:C++ ControlParameters::setForwardingFlags方法的具体用法?C++ ControlParameters::setForwardingFlags怎么用?C++ ControlParameters::setForwardingFlags使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ControlParameters的用法示例。


在下文中一共展示了ControlParameters::setForwardingFlags方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: commandInterest

void
Node::nfdRegisterPrefix
  (uint64_t registeredPrefixId, const ptr_lib::shared_ptr<const Name>& prefix,
   const OnInterestCallback& onInterest, const OnRegisterFailed& onRegisterFailed,
   const ForwardingFlags& flags, KeyChain& commandKeyChain,
   const Name& commandCertificateName, WireFormat& wireFormat, Face* face)
{
  if (!&commandKeyChain)
    throw runtime_error
      ("registerPrefix: The command KeyChain has not been set. You must call setCommandSigningInfo.");
  if (commandCertificateName.size() == 0)
    throw runtime_error
      ("registerPrefix: The command certificate name has not been set. You must call setCommandSigningInfo.");

  ControlParameters controlParameters;
  controlParameters.setName(*prefix);
  controlParameters.setForwardingFlags(flags);

  ptr_lib::shared_ptr<Interest> commandInterest(new Interest());
  if (isLocal()) {
    commandInterest->setName(Name("/localhost/nfd/rib/register"));
    // The interest is answered by the local host, so set a short timeout.
    commandInterest->setInterestLifetimeMilliseconds(2000.0);
  }
  else {
    commandInterest->setName(Name("/localhop/nfd/rib/register"));
    // The host is remote, so set a longer timeout.
    commandInterest->setInterestLifetimeMilliseconds(4000.0);
  }
  // NFD only accepts TlvWireFormat packets.
  commandInterest->getName().append
    (controlParameters.wireEncode(*TlvWireFormat::get()));
  makeCommandInterest
    (*commandInterest, commandKeyChain, commandCertificateName,
     *TlvWireFormat::get());

  if (registeredPrefixId != 0) {
    uint64_t interestFilterId = 0;
    if (onInterest) {
      // registerPrefix was called with the "combined" form that includes the
      // callback, so add an InterestFilterEntry.
      interestFilterId = getNextEntryId();
      setInterestFilter
        (interestFilterId, ptr_lib::make_shared<const InterestFilter>(*prefix),
         onInterest, face);
    }

    registeredPrefixTable_.push_back
      (ptr_lib::shared_ptr<RegisteredPrefix>(new RegisteredPrefix
        (registeredPrefixId, prefix, interestFilterId)));
  }

  // Send the registration interest.
  RegisterResponse response
    (ptr_lib::shared_ptr<RegisterResponse::Info>(new RegisterResponse::Info
     (this, prefix, onInterest, onRegisterFailed, flags, wireFormat, face)));
  // It is OK for func_lib::function make a copy of the function object because
  //   the Info is in a ptr_lib::shared_ptr.
  expressInterest
    (getNextEntryId(), commandInterest, response, response, wireFormat, face);
}
开发者ID:susmit85,项目名称:ndn-cpp,代码行数:61,代码来源:node.cpp


注:本文中的ControlParameters::setForwardingFlags方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。