本文整理匯總了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);
}
}
}
}