本文整理汇总了Python中pyndn.interest.Interest.setMaxSuffixComponents方法的典型用法代码示例。如果您正苦于以下问题:Python Interest.setMaxSuffixComponents方法的具体用法?Python Interest.setMaxSuffixComponents怎么用?Python Interest.setMaxSuffixComponents使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyndn.interest.Interest
的用法示例。
在下文中一共展示了Interest.setMaxSuffixComponents方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: expressInterest
# 需要导入模块: from pyndn.interest import Interest [as 别名]
# 或者: from pyndn.interest.Interest import setMaxSuffixComponents [as 别名]
def expressInterest(
self, interestOrName, arg2, arg3 = None, arg4 = None, arg5 = None):
"""
Send the Interest through the transport, read the entire response and
call onData(interest, data). There are two forms of expressInterest.
The first form takes the exact interest (including lifetime):
expressInterest(interest, onData [, onTimeout] [, wireFormat]).
The second form creates the interest from a name and optional
interest template:
expressInterest(name [, interestTemplate], onData [, onTimeout]
[, wireFormat]).
:param Interest interest: The Interest (if the first form is used). This
copies the Interest.
:param Name name: A name for the Interest (if the second form is used).
:param Interest interestTemplate: (optional) if not None, copy interest
selectors from the template (if the second form is used). If omitted,
use a default interest lifetime.
:param onData: When a matching data packet is received, this calls
onData(interest, data) where interest is the interest given to
expressInterest and data is the received Data object. NOTE: You must
not change the interest object - if you need to change it then make a
copy.
:type onData: function object
:param onTimeout: (optional) If the interest times out according to the
interest lifetime, this calls onTimeout(interest) where interest is
the interest given to expressInterest. However, if onTimeout is None
or omitted, this does not use it.
:type onTimeout: function object
:param wireFormat: (optional) A WireFormat object used to encode the
message. If omitted, use WireFormat.getDefaultWireFormat().
:type wireFormat: A subclass of WireFormat
:return: The pending interest ID which can be used with
removePendingInterest.
:rtype: int
"""
# 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.
interest = 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.
interest = Interest(interestOrName)
# 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
interest.setMinSuffixComponents(template.getMinSuffixComponents())
interest.setMaxSuffixComponents(template.getMaxSuffixComponents())
interest.setKeyLocator(template.getKeyLocator())
interest.setExclude(template.getExclude())
interest.setChildSelector(template.getChildSelector())
interest.setMustBeFresh(template.getMustBeFresh())
interest.setScope(template.getScope())
interest.setInterestLifetimeMilliseconds(
template.getInterestLifetimeMilliseconds())
# Don't copy the nonce.
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:
# Set a default interest lifetime.
interest.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 self._node.expressInterest(
interest, onData, onTimeout, wireFormat)