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


C# Interest.getInterestLifetimeMilliseconds方法代码示例

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


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

示例1: dumpInterest

 static void dumpInterest(Interest interest)
 {
     Console.Out.WriteLine("name: " + interest.getName().toUri());
       Console.Out.WriteLine("minSuffixComponents: " +
     (interest.getMinSuffixComponents() >= 0 ?
       "" + interest.getMinSuffixComponents() : "<none>"));
       Console.Out.WriteLine("maxSuffixComponents: " +
     (interest.getMaxSuffixComponents() >= 0 ?
       "" + interest.getMaxSuffixComponents() : "<none>"));
       Console.Out.Write("keyLocator: ");
       if (interest.getKeyLocator().getType() == KeyLocatorType.NONE)
     Console.Out.WriteLine("<none>");
       else if (interest.getKeyLocator().getType() ==KeyLocatorType.KEY_LOCATOR_DIGEST)
     Console.Out.WriteLine("KeyLocatorDigest: " + interest.getKeyLocator().getKeyData().toHex());
       else if (interest.getKeyLocator().getType() == KeyLocatorType.KEYNAME)
     Console.Out.WriteLine("KeyName: " + interest.getKeyLocator().getKeyName().toUri());
       else
     Console.Out.WriteLine("<unrecognized ndn_KeyLocatorType>");
       Console.Out.WriteLine
       ("exclude: " + (interest.getExclude().size() > 0 ?
     interest.getExclude().toUri() : "<none>"));
       Console.Out.WriteLine("lifetimeMilliseconds: " +
     (interest.getInterestLifetimeMilliseconds() >= 0 ?
       "" + interest.getInterestLifetimeMilliseconds() : "<none>"));
       Console.Out.WriteLine("childSelector: " +
     (interest.getChildSelector() >= 0 ?
       "" + interest.getChildSelector() : "<none>"));
       Console.Out.WriteLine("mustBeFresh: " + interest.getMustBeFresh());
       Console.Out.WriteLine("nonce: " +
     (interest.getNonce().size() > 0 ?
       "" + interest.getNonce().toHex() : "<none>"));
 }
开发者ID:named-data,项目名称:ndn-dot-net,代码行数:32,代码来源:test-encode-decode-interest.cs

示例2: generate

        /// <summary>
        /// Append a timestamp component and a random value component to interest's
        /// name. This ensures that the timestamp is greater than the timestamp used in
        /// the previous call. Then use keyChain to sign the interest which appends a
        /// SignatureInfo component and a component with the signature bits. If the
        /// interest lifetime is not set, this sets it.
        /// </summary>
        ///
        /// <param name="interest">The interest whose name is append with components.</param>
        /// <param name="keyChain">The KeyChain for calling sign.</param>
        /// <param name="certificateName">The certificate name of the key to use for signing.</param>
        /// <param name="wireFormat"></param>
        public void generate(Interest interest, KeyChain keyChain,
				Name certificateName, WireFormat wireFormat)
        {
            double timestamp;
             lock (lastTimestampLock_) {
                        timestamp = Math.Round(net.named_data.jndn.util.Common.getNowMilliseconds(),MidpointRounding.AwayFromZero);
                        while (timestamp <= lastTimestamp_)
                            timestamp += 1.0d;
                        // Update the timestamp now while it is locked. In the small chance that
                        //   signing fails, it just means that we have bumped the timestamp.
                        lastTimestamp_ = timestamp;
                    }

            // The timestamp is encoded as a TLV nonNegativeInteger.
            TlvEncoder encoder = new TlvEncoder(8);
            encoder.writeNonNegativeInteger((long) timestamp);
            interest.getName().append(new Blob(encoder.getOutput(), false));

            // The random value is a TLV nonNegativeInteger too, but we know it is 8 bytes,
            //   so we don't need to call the nonNegativeInteger encoder.
            ByteBuffer randomBuffer = ILOG.J2CsMapping.NIO.ByteBuffer.allocate(8);
            // Note: SecureRandom is thread safe.
            net.named_data.jndn.util.Common.getRandom().nextBytes(randomBuffer.array());
            interest.getName().append(new Blob(randomBuffer, false));

            keyChain.sign(interest, certificateName, wireFormat);

            if (interest.getInterestLifetimeMilliseconds() < 0)
                // The caller has not set the interest lifetime, so set it here.
                interest.setInterestLifetimeMilliseconds(1000.0d);
        }
开发者ID:named-data,项目名称:ndn-dot-net,代码行数:43,代码来源:CommandInterestGenerator.cs

示例3: PendingInterest

            /// <summary>
            /// Create a new PendingInterest and set the timeoutTime_ based on the current
            /// time and the interest lifetime.
            /// </summary>
            ///
            /// <param name="interest">The interest.</param>
            /// <param name="face">packet to the face.</param>
            public PendingInterest(Interest interest, Face face)
            {
                interest_ = interest;
                face_ = face;

                // Set up timeoutTimeMilliseconds_.
                if (interest_.getInterestLifetimeMilliseconds() >= 0.0d)
                    timeoutTimeMilliseconds_ = net.named_data.jndn.util.Common.getNowMilliseconds()
                            + interest_.getInterestLifetimeMilliseconds();
                else
                    // No timeout.
                    timeoutTimeMilliseconds_ = -1.0d;
            }
开发者ID:named-data,项目名称:ndn-dot-net,代码行数:20,代码来源:MemoryContentCache.cs

示例4: encodeInterest

        /// <summary>
        /// Encode interest using NDN-TLV and return the encoding.
        /// </summary>
        ///
        /// <param name="interest">The Interest object to encode.</param>
        /// <param name="signedPortionBeginOffset">name component and ends just before the final name component (which is assumed to be a signature for a signed interest).</param>
        /// <param name="signedPortionEndOffset">name component and ends just before the final name component (which is assumed to be a signature for a signed interest).</param>
        /// <returns>A Blob containing the encoding.</returns>
        public override Blob encodeInterest(Interest interest,
				int[] signedPortionBeginOffset, int[] signedPortionEndOffset)
        {
            TlvEncoder encoder = new TlvEncoder();
            int saveLength = encoder.getLength();

            // Encode backwards.
            encoder.writeOptionalNonNegativeIntegerTlv(net.named_data.jndn.encoding.tlv.Tlv.SelectedDelegation,
                    interest.getSelectedDelegationIndex());
            try {
                Blob linkWireEncoding = interest.getLinkWireEncoding(this);
                if (!linkWireEncoding.isNull())
                    // Encode the entire link as is.
                    encoder.writeBuffer(linkWireEncoding.buf());
            } catch (EncodingException ex) {
                throw new Exception(ex.Message);
            }

            encoder.writeOptionalNonNegativeIntegerTlvFromDouble(
                    net.named_data.jndn.encoding.tlv.Tlv.InterestLifetime,
                    interest.getInterestLifetimeMilliseconds());

            // Encode the Nonce as 4 bytes.
            if (interest.getNonce().size() == 0) {
                // This is the most common case. Generate a nonce.
                ByteBuffer nonce = ILOG.J2CsMapping.NIO.ByteBuffer.allocate(4);
                random_.nextBytes(nonce.array());
                encoder.writeBlobTlv(net.named_data.jndn.encoding.tlv.Tlv.Nonce, nonce);
            } else if (interest.getNonce().size() < 4) {
                ByteBuffer nonce_0 = ILOG.J2CsMapping.NIO.ByteBuffer.allocate(4);
                // Copy existing nonce bytes.
                nonce_0.put(interest.getNonce().buf());

                // Generate random bytes for remaining bytes in the nonce.
                for (int i = 0; i < 4 - interest.getNonce().size(); ++i)
                    nonce_0.put((byte) random_.Next());

                nonce_0.flip();
                encoder.writeBlobTlv(net.named_data.jndn.encoding.tlv.Tlv.Nonce, nonce_0);
            } else if (interest.getNonce().size() == 4)
                // Use the nonce as-is.
                encoder.writeBlobTlv(net.named_data.jndn.encoding.tlv.Tlv.Nonce, interest.getNonce().buf());
            else {
                // Truncate.
                ByteBuffer nonce_1 = interest.getNonce().buf();
                // buf() returns a new ByteBuffer, so we can change its limit.
                nonce_1.limit(nonce_1.position() + 4);
                encoder.writeBlobTlv(net.named_data.jndn.encoding.tlv.Tlv.Nonce, nonce_1);
            }

            encodeSelectors(interest, encoder);
            int[] tempSignedPortionBeginOffset = new int[1];
            int[] tempSignedPortionEndOffset = new int[1];
            encodeName(interest.getName(), tempSignedPortionBeginOffset,
                    tempSignedPortionEndOffset, encoder);
            int signedPortionBeginOffsetFromBack = encoder.getLength()
                    - tempSignedPortionBeginOffset[0];
            int signedPortionEndOffsetFromBack = encoder.getLength()
                    - tempSignedPortionEndOffset[0];

            encoder.writeTypeAndLength(net.named_data.jndn.encoding.tlv.Tlv.Interest, encoder.getLength()
                    - saveLength);
            signedPortionBeginOffset[0] = encoder.getLength()
                    - signedPortionBeginOffsetFromBack;
            signedPortionEndOffset[0] = encoder.getLength()
                    - signedPortionEndOffsetFromBack;

            return new Blob(encoder.getOutput(), false);
        }
开发者ID:named-data,项目名称:ndn-dot-net,代码行数:77,代码来源:Tlv0_2WireFormat.cs

示例5: expressInterestHelper

        /// <summary>
        /// Do the work of expressInterest once we know we are connected. Add the entry
        /// to the PIT, encode and send the interest.
        /// </summary>
        ///
        /// <param name="pendingInterestId"></param>
        /// <param name="interestCopy"></param>
        /// <param name="onData"></param>
        /// <param name="onTimeout"></param>
        /// <param name="onNetworkNack"></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>
        internal void expressInterestHelper(long pendingInterestId,
				Interest interestCopy, OnData onData, OnTimeout onTimeout,
				OnNetworkNack onNetworkNack, WireFormat wireFormat, Face face)
        {
            PendingInterestTable.Entry pendingInterest = pendingInterestTable_
                    .add(pendingInterestId, interestCopy, onData, onTimeout,
                            onNetworkNack);
            if (pendingInterest == null)
                // removePendingInterest was already called with the pendingInterestId.
                return;

            if (onTimeout != null
                    || interestCopy.getInterestLifetimeMilliseconds() >= 0.0d) {
                // Set up the timeout.
                double delayMilliseconds = interestCopy
                        .getInterestLifetimeMilliseconds();
                if (delayMilliseconds < 0.0d)
                    // Use a default timeout delay.
                    delayMilliseconds = 4000.0d;

                face.callLater(delayMilliseconds, new Node.Anonymous_C0 (this, pendingInterest));
            }

            // Special case: For timeoutPrefix_ we don't actually send the interest.
            if (!timeoutPrefix_.match(interestCopy.getName())) {
                Blob encoding = interestCopy.wireEncode(wireFormat);
                if (encoding.size() > getMaxNdnPacketSize())
                    throw new Exception(
                            "The encoded interest size exceeds the maximum limit getMaxNdnPacketSize()");
                transport_.send(encoding.buf());
            }
        }
开发者ID:named-data,项目名称:ndn-dot-net,代码行数:46,代码来源:Node.cs

示例6: dumpInterest

 private static ArrayList dumpInterest(Interest interest)
 {
     ArrayList result = new ArrayList();
     ILOG.J2CsMapping.Collections.Collections.Add(result,dump("name:", interest.getName().toUri()));
     ILOG.J2CsMapping.Collections.Collections.Add(result,dump(
                     "minSuffixComponents:",
                     (interest.getMinSuffixComponents() >= 0) ? (Object) (interest.getMinSuffixComponents()) : (Object) ("<none>")));
     ILOG.J2CsMapping.Collections.Collections.Add(result,dump(
                     "maxSuffixComponents:",
                     (interest.getMaxSuffixComponents() >= 0) ? (Object) (interest.getMaxSuffixComponents()) : (Object) ("<none>")));
     if (interest.getKeyLocator().getType() != net.named_data.jndn.KeyLocatorType.NONE) {
         if (interest.getKeyLocator().getType() == net.named_data.jndn.KeyLocatorType.KEY_LOCATOR_DIGEST)
             ILOG.J2CsMapping.Collections.Collections.Add(result,dump("keyLocator: KeyLocatorDigest:", interest
                                     .getKeyLocator().getKeyData().toHex()));
         else if (interest.getKeyLocator().getType() == net.named_data.jndn.KeyLocatorType.KEYNAME)
             ILOG.J2CsMapping.Collections.Collections.Add(result,dump("keyLocator: KeyName:", interest
                                     .getKeyLocator().getKeyName().toUri()));
         else
             ILOG.J2CsMapping.Collections.Collections.Add(result,dump("keyLocator: <unrecognized KeyLocatorType"));
     } else
         ILOG.J2CsMapping.Collections.Collections.Add(result,dump("keyLocator: <none>"));
     ILOG.J2CsMapping.Collections.Collections.Add(result,dump("exclude:", (interest.getExclude().size() > 0) ? interest
                     .getExclude().toUri() : "<none>"));
     ILOG.J2CsMapping.Collections.Collections.Add(result,dump("childSelector:",
                     (interest.getChildSelector() >= 0) ? (Object) (interest.getChildSelector())
                             : (Object) ("<none>")));
     ILOG.J2CsMapping.Collections.Collections.Add(result,dump("mustBeFresh:", (interest.getMustBeFresh()) ? "true"
                     : "false"));
     ILOG.J2CsMapping.Collections.Collections.Add(result,dump("nonce:", (interest.getNonce().size() == 0) ? "<none>"
                     : interest.getNonce().toHex()));
     ILOG.J2CsMapping.Collections.Collections.Add(result,dump("lifetimeMilliseconds:",
                     (interest.getInterestLifetimeMilliseconds() < 0) ? "<none>" : ""
                             + (long) interest.getInterestLifetimeMilliseconds()));
     return result;
 }
开发者ID:named-data,项目名称:ndn-dot-net,代码行数:35,代码来源:TestInterestMethods.cs


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