本文整理汇总了C#中net.named_data.jndn.Interest.setChildSelector方法的典型用法代码示例。如果您正苦于以下问题:C# Interest.setChildSelector方法的具体用法?C# Interest.setChildSelector怎么用?C# Interest.setChildSelector使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.named_data.jndn.Interest
的用法示例。
在下文中一共展示了Interest.setChildSelector方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main(string[] args)
{
var interest = new Interest();
interest.wireDecode(new Blob(TlvInterest));
Console.Out.WriteLine("Interest:");
dumpInterest(interest);
// Set the name again to clear the cached encoding so we encode again.
interest.setName(interest.getName());
var encoding = interest.wireEncode();
Console.Out.WriteLine("");
Console.Out.WriteLine("Re-encoded interest " + encoding.toHex());
var reDecodedInterest = new Interest();
reDecodedInterest.wireDecode(encoding);
Console.Out.WriteLine("");
Console.Out.WriteLine("Re-decoded Interest:");
dumpInterest(reDecodedInterest);
var freshInterest = new Interest(new Name("/ndn/abc"));
freshInterest.setMinSuffixComponents(4);
freshInterest.setMaxSuffixComponents(6);
freshInterest.setInterestLifetimeMilliseconds(30000);
freshInterest.setChildSelector(1);
freshInterest.setMustBeFresh(true);
freshInterest.getKeyLocator().setType(KeyLocatorType.KEY_LOCATOR_DIGEST);
freshInterest.getKeyLocator().setKeyData
(new Blob(new byte[] {
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F }));
freshInterest.getExclude().appendComponent(new Name("abc").get(0)).appendAny();
var identityStorage = new MemoryIdentityStorage();
var privateKeyStorage = new MemoryPrivateKeyStorage();
var keyChain = new KeyChain
(new IdentityManager(identityStorage, privateKeyStorage),
new SelfVerifyPolicyManager(identityStorage));
// Initialize the storage.
var keyName = new Name("/testname/DSK-123");
var certificateName = keyName.getSubName(0, keyName.size() - 1).append
("KEY").append(keyName.get(-1)).append("ID-CERT").append("0");
identityStorage.addKey(keyName, KeyType.RSA, new Blob(DEFAULT_RSA_PUBLIC_KEY_DER));
privateKeyStorage.setKeyPairForKeyName
(keyName, KeyType.RSA, new ByteBuffer(DEFAULT_RSA_PUBLIC_KEY_DER),
new ByteBuffer(DEFAULT_RSA_PRIVATE_KEY_DER));
// Make a Face just so that we can sign the interest.
var face = new Face("localhost");
face.setCommandSigningInfo(keyChain, certificateName);
face.makeCommandInterest(freshInterest);
Interest reDecodedFreshInterest = new Interest();
reDecodedFreshInterest.wireDecode(freshInterest.wireEncode());
Console.Out.WriteLine("");
Console.Out.WriteLine("Re-decoded fresh Interest:");
dumpInterest(reDecodedFreshInterest);
VerifyCallbacks callbacks = new VerifyCallbacks("Freshly-signed Interest");
keyChain.verifyInterest(reDecodedFreshInterest, callbacks, callbacks);
}
示例2: testEncodeDecodeInterestWithLink
public void testEncodeDecodeInterestWithLink()
{
Link link1 = new Link();
link1.setName(new Name("test"));
link1.addDelegation(10, new Name("/test1"));
link1.addDelegation(20, new Name("/test2"));
link1.addDelegation(100, new Name("/test3"));
try {
keyChain.sign(link1, certificateName);
} catch (SecurityException ex) {
Assert.Fail(ex.Message);
}
Interest interestA = new Interest();
interestA.setName(new Name("/Test/Encode/Decode/With/Link"));
interestA.setChildSelector(1);
interestA.setInterestLifetimeMilliseconds(10000);
interestA.setLinkWireEncoding(link1.wireEncode());
Blob interestEncoding = interestA.wireEncode();
Interest interestB = new Interest();
try {
interestB.wireDecode(interestEncoding);
} catch (EncodingException ex_0) {
Assert.Fail(ex_0.Message);
}
Assert.AssertEquals(interestA.getName(), interestB.getName());
Link link2 = null;
try {
link2 = interestB.getLink();
} catch (Exception ex_1) {
Assert.Fail("interestB.getLink(): " + ex_1.Message);
}
Assert.AssertTrue("Interest link object not specified", link2 != null);
DelegationSet delegations = link2.getDelegations();
for (int i = 0; i < delegations.size(); ++i) {
if (i == 0) {
Assert.AssertEquals(10, delegations.get(i).getPreference());
Assert.AssertEquals(new Name("/test1"), delegations.get(i).getName());
}
if (i == 1) {
Assert.AssertEquals(20, delegations.get(i).getPreference());
Assert.AssertEquals(new Name("/test2"), delegations.get(i).getName());
}
if (i == 2) {
Assert.AssertEquals(100, delegations.get(i).getPreference());
Assert.AssertEquals(new Name("/test3"), delegations.get(i).getName());
}
}
}
示例3: fetchNextSegment
private void fetchNextSegment(Interest originalInterest_0, Name dataName,
long segment)
{
// Start with the original Interest to preserve any special selectors.
Interest interest = new Interest(originalInterest_0);
// Changing a field clears the nonce so that the library will generate a new one.
interest.setChildSelector(0);
interest.setMustBeFresh(false);
interest.setName(dataName.getPrefix(-1).appendSegment(segment));
try {
face_.expressInterest(interest, this, this);
} catch (IOException ex) {
try {
onError_.onError(net.named_data.jndn.util.SegmentFetcher.ErrorCode.IO_ERROR,
"I/O error fetching the next segment " + ex);
} catch (Exception exception) {
logger_.log(ILOG.J2CsMapping.Util.Logging.Level.SEVERE, "Error in onError", exception);
}
}
}
示例4: decodeSelectors
private static void decodeSelectors(Interest interest, TlvDecoder decoder,
bool copy)
{
int endOffset = decoder.readNestedTlvsStart(net.named_data.jndn.encoding.tlv.Tlv.Selectors);
interest.setMinSuffixComponents((int) decoder
.readOptionalNonNegativeIntegerTlv(net.named_data.jndn.encoding.tlv.Tlv.MinSuffixComponents,
endOffset));
interest.setMaxSuffixComponents((int) decoder
.readOptionalNonNegativeIntegerTlv(net.named_data.jndn.encoding.tlv.Tlv.MaxSuffixComponents,
endOffset));
if (decoder.peekType(net.named_data.jndn.encoding.tlv.Tlv.PublisherPublicKeyLocator, endOffset))
decodeKeyLocator(net.named_data.jndn.encoding.tlv.Tlv.PublisherPublicKeyLocator,
interest.getKeyLocator(), decoder, copy);
else
interest.getKeyLocator().clear();
if (decoder.peekType(net.named_data.jndn.encoding.tlv.Tlv.Exclude, endOffset))
decodeExclude(interest.getExclude(), decoder, copy);
else
interest.getExclude().clear();
interest.setChildSelector((int) decoder
.readOptionalNonNegativeIntegerTlv(net.named_data.jndn.encoding.tlv.Tlv.ChildSelector, endOffset));
interest.setMustBeFresh(decoder.readBooleanTlv(net.named_data.jndn.encoding.tlv.Tlv.MustBeFresh,
endOffset));
decoder.finishNestedTlvs(endOffset);
}
示例5: fetchFirstSegment
private void fetchFirstSegment(Interest baseInterest)
{
Interest interest = new Interest(baseInterest);
interest.setChildSelector(1);
interest.setMustBeFresh(true);
try {
face_.expressInterest(interest, this, this);
} catch (IOException ex) {
try {
onError_.onError(net.named_data.jndn.util.SegmentFetcher.ErrorCode.IO_ERROR,
"I/O error fetching the first segment " + ex);
} catch (Exception exception) {
logger_.log(ILOG.J2CsMapping.Util.Logging.Level.SEVERE, "Error in onError", exception);
}
}
}