本文整理汇总了Python中pyndn.interest.Interest.setName方法的典型用法代码示例。如果您正苦于以下问题:Python Interest.setName方法的具体用法?Python Interest.setName怎么用?Python Interest.setName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyndn.interest.Interest
的用法示例。
在下文中一共展示了Interest.setName方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _fetchNextSegment
# 需要导入模块: from pyndn.interest import Interest [as 别名]
# 或者: from pyndn.interest.Interest import setName [as 别名]
def _fetchNextSegment(self, originalInterest, dataName, segment):
# Start with the original Interest to preserve any special selectors.
interest = Interest(originalInterest)
# Changing a field clears the nonce so that the library will
# generate a new one.
interest.setMustBeFresh(False)
interest.setName(dataName.getPrefix(-1).appendSegment(segment))
self._face.expressInterest(interest, self._onData, self._onTimeout)
示例2: _nfdRegisterPrefix
# 需要导入模块: from pyndn.interest import Interest [as 别名]
# 或者: from pyndn.interest.Interest import setName [as 别名]
def _nfdRegisterPrefix(
self, registeredPrefixId, prefix, onInterest, onRegisterFailed, flags,
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(flags)
commandInterest = Interest()
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())
if registeredPrefixId != 0:
interestFilterId = 0
if onInterest != None:
# registerPrefix was called with the "combined" form that includes
# the callback, so add an InterestFilterEntry.
interestFilterId = self.getNextEntryId()
self.setInterestFilter(
interestFilterId, InterestFilter(prefix), onInterest, face)
self._registeredPrefixTable.append(Node._RegisteredPrefix(
registeredPrefixId, prefix, interestFilterId))
# Send the registration interest.
response = Node._RegisterResponse(
self, prefix, onInterest, onRegisterFailed, flags,
TlvWireFormat.get(), True, face)
self.expressInterest(
self.getNextEntryId(), commandInterest, response.onData,
response.onTimeout, TlvWireFormat.get(), face)
示例3: _nfdRegisterPrefix
# 需要导入模块: from pyndn.interest import Interest [as 别名]
# 或者: from pyndn.interest.Interest import setName [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)
示例4: _getExpressInterestArgs
# 需要导入模块: from pyndn.interest import Interest [as 别名]
# 或者: from pyndn.interest.Interest import setName [as 别名]
def _getExpressInterestArgs(self, interestOrName, arg2, arg3, arg4, arg5, arg6):
"""
This is a protected helper method to resolve the different overloaded
forms of Face.expressInterest and return the arguments to pass to
Node.expressInterest. This is necessary to prepare arguments such as
interestCopy before dispatching to Node.expressInterest.
:return: A dictionary with the following keys: 'pendingInterestId',
'interestCopy', 'onData', 'onTimeout', 'onNetworkNack' and 'wireFormat'.
:rtype: dict
"""
if isinstance(interestOrName, Interest):
# Node.expressInterest requires a copy of the interest.
interestCopy = Interest(interestOrName)
else:
# The first argument is a name. Make the interest from the name and
# possible template.
if isinstance(arg2, Interest):
template = arg2
# Copy the template.
interestCopy = Interest(template)
interestCopy.setName(interestOrName)
# Shift the remaining args to be processed below.
arg2 = arg3
arg3 = arg4
arg4 = arg5
arg5 = arg6
else:
# No template.
interestCopy = Interest(interestOrName)
# Set a default interest lifetime.
interestCopy.setInterestLifetimeMilliseconds(4000.0)
onData = arg2
# arg3, arg4, arg5 may be:
# OnTimeout, OnNetworkNack, WireFormat
# OnTimeout, OnNetworkNack, None
# OnTimeout, WireFormat, None
# OnTimeout, None, None
# WireFormat, None, None
# None, None, None
if isinstance(arg3, collections.Callable):
onTimeout = arg3
else:
onTimeout = None
if isinstance(arg4, collections.Callable):
onNetworkNack = arg4
else:
onNetworkNack = None
if isinstance(arg3, WireFormat):
wireFormat = arg3
elif isinstance(arg4, WireFormat):
wireFormat = arg4
elif isinstance(arg5, WireFormat):
wireFormat = arg5
else:
wireFormat = WireFormat.getDefaultWireFormat()
return { 'pendingInterestId': self._node.getNextEntryId(),
'interestCopy': interestCopy, 'onData': onData, 'onTimeout': onTimeout,
'onNetworkNack': onNetworkNack, 'wireFormat': wireFormat }
示例5: _getExpressInterestArgs
# 需要导入模块: from pyndn.interest import Interest [as 别名]
# 或者: from pyndn.interest.Interest import setName [as 别名]
def _getExpressInterestArgs(self, interestOrName, arg2, arg3, arg4, arg5):
"""
This is a protected helper method to resolve the different overloaded
forms of Face.expressInterest and return the arguments to pass to
Node.expressInterest. This is necessary to prepare arguments such as
interestCopy before dispatching to Node.expressInterest.
:return: A dictionary with the following keys: 'pendingInterestId',
'interestCopy', 'onData', 'onTimeout' and 'wireFormat'.
:rtype: dict
"""
# expressInterest(interest, onData)
# expressInterest(interest, onData, wireFormat)
# expressInterest(interest, onData, onTimeout)
# expressInterest(interest, onData, onTimeout, wireFormat)
if type(interestOrName) is Interest:
# Node.expressInterest requires a copy of the interest.
interestCopy = Interest(interestOrName)
onData = arg2
if isinstance(arg3, WireFormat):
onTimeout = None
wireFormat = arg3
else:
onTimeout = arg3
wireFormat = arg4
else:
# The first argument is a name. Make the interest from the name and
# possible template.
# expressInterest(name, interestTemplate, onData)
# expressInterest(name, interestTemplate, onData, wireFormat)
# expressInterest(name, interestTemplate, onData, onTimeout)
# expressInterest(name, interestTemplate, onData, onTimeout, wireFormat)
if type(arg2) is Interest:
template = arg2
# Copy the template.
interestCopy = Interest(template)
interestCopy.setName(interestOrName)
onData = arg3
if isinstance(arg4, WireFormat):
onTimeout = None
wireFormat = arg4
else:
onTimeout = arg4
wireFormat = arg5
# expressInterest(name, onData)
# expressInterest(name, onData, wireFormat)
# expressInterest(name, onData, onTimeout)
# expressInterest(name, onData, onTimeout, wireFormat)
else:
interestCopy = Interest(interestOrName)
# Set a default interest lifetime.
interestCopy.setInterestLifetimeMilliseconds(4000.0)
onData = arg2
if isinstance(arg3, WireFormat):
onTimeout = None
wireFormat = arg3
else:
onTimeout = arg3
wireFormat = arg4
if wireFormat == None:
# Don't use a default argument since getDefaultWireFormat can change.
wireFormat = WireFormat.getDefaultWireFormat()
return { 'pendingInterestId': self._node.getNextEntryId(),
'interestCopy': interestCopy, 'onData': onData, 'onTimeout': onTimeout,
'wireFormat': wireFormat }