本文整理汇总了C#中net.named_data.jndn.Interest.matchesName方法的典型用法代码示例。如果您正苦于以下问题:C# Interest.matchesName方法的具体用法?C# Interest.matchesName怎么用?C# Interest.matchesName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.named_data.jndn.Interest
的用法示例。
在下文中一共展示了Interest.matchesName方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: onInterest
public void onInterest(Name prefix, Interest interest, Face face,
long interestFilterId, InterestFilter filter)
{
doCleanup();
Name.Component selectedComponent = null;
Blob selectedEncoding = null;
// We need to iterate over both arrays.
int totalSize = staleTimeCache_.Count + noStaleTimeCache_.Count;
for (int i = 0; i < totalSize; ++i) {
MemoryContentCache.Content content;
if (i < staleTimeCache_.Count)
content = staleTimeCache_[i];
else
// We have iterated over the first array. Get from the second.
content = noStaleTimeCache_[i - staleTimeCache_.Count];
if (interest.matchesName(content.getName())) {
if (interest.getChildSelector() < 0) {
// No child selector, so send the first match that we have found.
try {
face.send(content.getDataEncoding());
} catch (IOException ex) {
ILOG.J2CsMapping.Util.Logging.Logger.getLogger(typeof(MemoryContentCache).FullName)
.log(ILOG.J2CsMapping.Util.Logging.Level.SEVERE, null, ex);
}
return;
} else {
// Update selectedEncoding based on the child selector.
Name.Component component;
if (content.getName().size() > interest.getName().size())
component = content.getName().get(
interest.getName().size());
else
component = emptyComponent_;
bool gotBetterMatch = false;
if (selectedEncoding == null)
// Save the first match.
gotBetterMatch = true;
else {
if (interest.getChildSelector() == 0) {
// Leftmost child.
if (component.compare(selectedComponent) < 0)
gotBetterMatch = true;
} else {
// Rightmost child.
if (component.compare(selectedComponent) > 0)
gotBetterMatch = true;
}
}
if (gotBetterMatch) {
selectedComponent = component;
selectedEncoding = content.getDataEncoding();
}
}
}
}
if (selectedEncoding != null) {
// We found the leftmost or rightmost child.
try {
face.send(selectedEncoding);
} catch (IOException ex_0) {
ILOG.J2CsMapping.Util.Logging.Logger.getLogger(typeof(MemoryContentCache).FullName).log(
ILOG.J2CsMapping.Util.Logging.Level.SEVERE, null, ex_0);
}
} else {
// Call the onDataNotFound callback (if defined).
Object onDataNotFound = ILOG.J2CsMapping.Collections.Collections.Get(onDataNotFoundForPrefix_,prefix.toUri());
if (onDataNotFound != null) {
try {
((OnInterestCallback) onDataNotFound).onInterest(prefix,
interest, face, interestFilterId, filter);
} catch (Exception ex_1) {
logger_.log(ILOG.J2CsMapping.Util.Logging.Level.SEVERE, "Error in onDataNotFound", ex_1);
}
}
}
}