本文整理汇总了Python中pyndn.interest.Interest.setCanBePrefix方法的典型用法代码示例。如果您正苦于以下问题:Python Interest.setCanBePrefix方法的具体用法?Python Interest.setCanBePrefix怎么用?Python Interest.setCanBePrefix使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyndn.interest.Interest
的用法示例。
在下文中一共展示了Interest.setCanBePrefix方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _nfdRegisterPrefix
# 需要导入模块: from pyndn.interest import Interest [as 别名]
# 或者: from pyndn.interest.Interest import setCanBePrefix [as 别名]
def _nfdRegisterPrefix(
self, registeredPrefixId, prefix, onInterest, onRegisterFailed,
onRegisterSuccess, registrationOptions, commandKeyChain,
commandCertificateName, face):
"""
Do the work of registerPrefix to register with NFD.
:param int registeredPrefixId: The getNextEntryId() which registerPrefix
got so it could return it to the caller. If this is 0, then don't add
to _registeredPrefixTable (assuming it has already been done).
"""
if commandKeyChain == None:
raise RuntimeError(
"registerPrefix: The command KeyChain has not been set. You must call setCommandSigningInfo.")
if commandCertificateName.size() == 0:
raise RuntimeError(
"registerPrefix: The command certificate name has not been set. You must call setCommandSigningInfo.")
controlParameters = ControlParameters()
controlParameters.setName(prefix)
controlParameters.setForwardingFlags(registrationOptions)
if (registrationOptions.getOrigin() != None and
registrationOptions.getOrigin() >= 0):
controlParameters.setOrigin(registrationOptions.getOrigin())
# Remove the origin value from the flags since it is not used to encode.
controlParameters.getForwardingFlags().setOrigin(None)
commandInterest = Interest()
commandInterest.setCanBePrefix(True)
if self.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()))
self.makeCommandInterest(
commandInterest, commandKeyChain, commandCertificateName,
TlvWireFormat.get())
# Send the registration interest.
response = Node._RegisterResponse(
prefix, onRegisterFailed, onRegisterSuccess, registeredPrefixId, self,
onInterest, face)
self.expressInterest(
self.getNextEntryId(), commandInterest, response.onData,
response.onTimeout, None, TlvWireFormat.get(), face)