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


C# Interest.refreshNonce方法代码示例

本文整理汇总了C#中net.named_data.jndn.Interest.refreshNonce方法的典型用法代码示例。如果您正苦于以下问题:C# Interest.refreshNonce方法的具体用法?C# Interest.refreshNonce怎么用?C# Interest.refreshNonce使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.named_data.jndn.Interest的用法示例。


在下文中一共展示了Interest.refreshNonce方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: expressInterest

        /// <summary>
        /// Send the Interest through the transport, read the entire response and call
        /// onData, onTimeout or onNetworkNack as described below.
        /// </summary>
        ///
        /// <param name="pendingInterestId"></param>
        /// <param name="interestCopy">to use.</param>
        /// <param name="onData">expressInterest and data is the received Data object.</param>
        /// <param name="onTimeout">interest given to expressInterest. If onTimeout is null, this does not use it.</param>
        /// <param name="onNetworkNack">onNetworkNack.onNetworkNack(interest, networkNack) and does not call onTimeout. However, if a network Nack is received and onNetworkNack is null, do nothing and wait for the interest to time out.</param>
        /// <param name="wireFormat">A WireFormat object used to encode the message.</param>
        /// <param name="face"></param>
        /// <exception cref="IOException">For I/O error in sending the interest.</exception>
        /// <exception cref="System.Exception">If the encoded interest size exceeds getMaxNdnPacketSize().</exception>
        public void expressInterest(long pendingInterestId,
				Interest interestCopy, OnData onData,
				OnTimeout onTimeout, OnNetworkNack onNetworkNack,
				WireFormat wireFormat, Face face)
        {
            // Set the nonce in our copy of the Interest so it is saved in the PIT.
            interestCopy.setNonce(nonceTemplate_);
            interestCopy.refreshNonce();

            if (connectStatus_ == net.named_data.jndn.Node.ConnectStatus.CONNECT_COMPLETE) {
                // We are connected. Simply send the interest without synchronizing.
                expressInterestHelper(pendingInterestId, interestCopy, onData,
                        onTimeout, onNetworkNack, wireFormat, face);
                return;
            }

             lock (onConnectedCallbacks_) {
                        // TODO: Properly check if we are already connected to the expected host.
                        if (!transport_.isAsync()) {
                            // The simple case: Just do a blocking connect and express.
                            transport_.connect(connectionInfo_, this, null);
                            expressInterestHelper(pendingInterestId, interestCopy, onData,
                                    onTimeout, onNetworkNack, wireFormat, face);
                            // Make future calls to expressInterest send directly to the Transport.
                            connectStatus_ = net.named_data.jndn.Node.ConnectStatus.CONNECT_COMPLETE;

                            return;
                        }

                        // Handle the async case.
                        if (connectStatus_ == net.named_data.jndn.Node.ConnectStatus.UNCONNECTED) {
                            connectStatus_ = net.named_data.jndn.Node.ConnectStatus.CONNECT_REQUESTED;

                            // expressInterestHelper will be called by onConnected.
                            ILOG.J2CsMapping.Collections.Collections.Add(onConnectedCallbacks_,new Node.Anonymous_C3 (this, interestCopy, onNetworkNack, face,
                                                    onTimeout, pendingInterestId, wireFormat, onData));

                            IRunnable onConnected = new Node.Anonymous_C2 (this);
                            transport_.connect(connectionInfo_, this, onConnected);
                        } else if (connectStatus_ == net.named_data.jndn.Node.ConnectStatus.CONNECT_REQUESTED) {
                            // Still connecting. add to the interests to express by onConnected.
                            ILOG.J2CsMapping.Collections.Collections.Add(onConnectedCallbacks_,new Node.Anonymous_C1 (this, interestCopy, onData, onTimeout,
                                                    onNetworkNack, wireFormat, face, pendingInterestId));
                        } else if (connectStatus_ == net.named_data.jndn.Node.ConnectStatus.CONNECT_COMPLETE)
                            // We have to repeat this check for CONNECT_COMPLETE in case the
                            // onConnected callback was called while we were waiting to enter this
                            // synchronized block.
                            expressInterestHelper(pendingInterestId, interestCopy, onData,
                                    onTimeout, onNetworkNack, wireFormat, face);
                        else
                            // Don't expect this to happen.
                            throw new Exception("Node: Unrecognized _connectStatus "
                                    + connectStatus_);
                    }
        }
开发者ID:named-data,项目名称:ndn-dot-net,代码行数:69,代码来源:Node.cs

示例2: testRefreshNonce

        public void testRefreshNonce()
        {
            Interest interest = new Interest(referenceInterest);
            Blob oldNonce = interest.getNonce();
            Assert.AssertEquals(4, oldNonce.size());

            interest.refreshNonce();
            Assert.AssertEquals("The refreshed nonce should be the same size",
                    oldNonce.size(), interest.getNonce().size());
            Assert.AssertFalse("The refreshed nonce should be different", interest
                    .getNonce().equals(oldNonce));
        }
开发者ID:named-data,项目名称:ndn-dot-net,代码行数:12,代码来源:TestInterestMethods.cs


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