本文整理汇总了Python中pyndn.Data.content方法的典型用法代码示例。如果您正苦于以下问题:Python Data.content方法的具体用法?Python Data.content怎么用?Python Data.content使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyndn.Data
的用法示例。
在下文中一共展示了Data.content方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: onInterest
# 需要导入模块: from pyndn import Data [as 别名]
# 或者: from pyndn.Data import content [as 别名]
def onInterest(self, prefix, interest, face, interestFilterId, filter):
"""
Append the next segment number to the prefix and send a new data packet.
If the last packet is sent, then call self._onFinished().
"""
maxSegment = 2
if self._segment >= maxSegment:
# We have already called self._onFinished().
return
dump("Got interest", interest.toUri())
# Make and sign a Data packet for the segment.
self._segment += 1
data = Data(Name(prefix).appendSegment(self._segment))
content = "Segment number " + repr(self._segment)
data.content = content
self._keyChain.sign(data, self._certificateName)
face.putData(data)
dump("Sent data packet", data.name.toUri())
if self._segment >= maxSegment:
# We sent the final data packet.
self._onFinished()
示例2: onInterest
# 需要导入模块: from pyndn import Data [as 别名]
# 或者: from pyndn.Data import content [as 别名]
def onInterest(self, prefix, interest, face, interestFilterId, filter):
"""
Create and send a Data packet with the interest name.
If the last packet is sent, then set self._enabled[0] = False.
"""
dump("Got interest", interest.toUri())
# Make and sign a Data packet with the interest name.
data = Data(interest.name)
content = "Data packet " + interest.name.toUri()
data.content = content
self._keyChain.sign(data, self._certificateName)
face.putData(data)
dump("Sent data packet", data.name.toUri())
self._nSegmentsSent += 1
if self._nSegmentsSent >= (self._endBlockId - self._startBlockId) + 1:
# We sent the final segment.
self._onFinished()