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


Python Data.content方法代码示例

本文整理汇总了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()
开发者ID:named-data,项目名称:PyNDN2,代码行数:27,代码来源:watched_insertion.py

示例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()
开发者ID:named-data,项目名称:PyNDN2,代码行数:22,代码来源:basic_insertion.py


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