/// <summary> /// Create a new Entry with the given values. /// </summary> /// /// <param name="interestFilterId">The ID from Node.getNextEntryId().</param> /// <param name="filter">The InterestFilter for this entry.</param> /// <param name="onInterest">The callback to call.</param> /// <param name="face"></param> public Entry(long interestFilterId, InterestFilter filter, OnInterestCallback onInterest, Face face) { interestFilterId_ = interestFilterId; filter_ = filter; onInterest_ = onInterest; face_ = face; }
/// <summary> /// Call setInterestFilter on the Face given to the constructor so that this /// MemoryContentCache will answer interests whose name matches the filter. /// </summary> /// /// <param name="filter"></param> /// <param name="onDataNotFound">onDataNotFound.onInterest(prefix, interest, face, interestFilterId, filter). Your callback can find the Data packet for the interest and call face.putData(data). Note: If you call setInterestFilter multiple times where filter.getPrefix() is the same, it is undetermined which onDataNotFound will be called. If your callback cannot find the Data packet, it can optionally call storePendingInterest(interest, face) to store the pending interest in this object to be satisfied by a later call to add(data). If you want to automatically store all pending interests, you can simply use getStorePendingInterest() for onDataNotFound. If onDataNotFound is null, this does not use it. NOTE: The library will log any exceptions thrown by this callback, but for better error handling the callback should catch and properly handle any exceptions.</param> public void setInterestFilter(InterestFilter filter, OnInterestCallback onDataNotFound) { if (onDataNotFound != null) { ILOG.J2CsMapping.Collections.Collections.Put(onDataNotFoundForPrefix_, filter.getPrefix().toUri(), onDataNotFound); } long interestFilterId = face_.setInterestFilter(filter, this); ILOG.J2CsMapping.Collections.Collections.Add(interestFilterIdList_, interestFilterId); }
public void onInterest(Name prefix, Interest interest, Face face, long interestFilterId, InterestFilter filter) { ++interestCallbackCount[0]; Data data = new Data(interest.getName()); data.setContent(new Blob("SUCCESS")); try { outer_TestFaceCallRegisterMethods.keyChain.sign(data, outer_TestFaceCallRegisterMethods.certificateName); } catch (SecurityException ex) { net.named_data.jndn.tests.integration_tests.TestFaceCallRegisterMethods.logger.log(ILOG.J2CsMapping.Util.Logging.Level.SEVERE, null, ex); } try { face.putData(data); } catch (IOException ex_0) { net.named_data.jndn.tests.integration_tests.TestFaceCallRegisterMethods.logger.log(ILOG.J2CsMapping.Util.Logging.Level.SEVERE, null, ex_0); } }
public void onInterest(Name prefix, Interest interest, Face face, long interestFilterId, InterestFilter filter) { Data data = outer_AccessManagerV2.storage_.find(interest); if (data != null) { net.named_data.jndn.encrypt.AccessManagerV2.logger_.log(ILOG.J2CsMapping.Util.Logging.Level.INFO, "Serving {0} from in-memory-storage", data.getName()); try { face.putData(data); } catch (Exception ex) { net.named_data.jndn.encrypt.AccessManagerV2.logger_.log(ILOG.J2CsMapping.Util.Logging.Level.SEVERE, "AccessManagerV2: Error in Face.putData", ex); } } else { net.named_data.jndn.encrypt.AccessManagerV2.logger_.log(ILOG.J2CsMapping.Util.Logging.Level.INFO, "Didn't find data for {0}", interest.getName()); // TODO: Send NACK? } }
public void onInterest(Name localPrefix, Interest localInterest, Face localFace, long localInterestFilterId, InterestFilter localFilter) { outer_MemoryContentCache.storePendingInterest(localInterest, localFace); }
public void onInterest(Name prefix, Interest interest, Face face, long interestFilterId, InterestFilter filter) { logger_.log(ILOG.J2CsMapping.Util.Logging.Level.INFO, "MemoryContentCache: Received Interest {0}", interest.toUri()); double nowMilliseconds = net.named_data.jndn.util.Common.getNowMilliseconds(); doCleanup(nowMilliseconds); 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; bool isFresh = true; if (i < staleTimeCache_.Count) { MemoryContentCache.StaleTimeContent staleTimeContent = staleTimeCache_[i]; content = staleTimeContent; isFresh = staleTimeContent.isFresh(nowMilliseconds); } else { // We have iterated over the first array. Get from the second. content = noStaleTimeCache_[i - staleTimeCache_.Count]; } if (interest.matchesName(content.getName()) && !(interest.getMustBeFresh() && !isFresh)) { if (interest.getChildSelector() < 0) { // No child selector, so send the first match that we have found. logger_.log(ILOG.J2CsMapping.Util.Logging.Level.INFO, "MemoryContentCache: Reply Data {0}", content.getName()); try { face.send(content.getDataEncoding()); } catch (IOException ex) { logger_.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 { logger_.log(ILOG.J2CsMapping.Util.Logging.Level.INFO, "MemoryContentCache: Reply Data to Interest {0}", interest.toUri()); face.send(selectedEncoding); } catch (IOException ex_0) { logger_.log(ILOG.J2CsMapping.Util.Logging.Level.SEVERE, null, ex_0); } } else { logger_.log(ILOG.J2CsMapping.Util.Logging.Level.INFO, "MemoryContentCache: onDataNotFound for {0}", interest.toUri()); // 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); } } } }
/// <summary> /// Call setInterestFilter on the Face given to the constructor so that this /// MemoryContentCache will answer interests whose name has the prefix. /// Do not call a callback if a data packet is not found in the cache. /// </summary> /// /// <param name="filter"></param> public void setInterestFilter(InterestFilter filter) { setInterestFilter(filter, null); }
public void onInterest(Name prefix, Interest interest, Face face, long interestFilterId, InterestFilter filter) { logTextBox.text += "\n" + "Got a status interest with name: " + prefix.ToString(); logTextBox.text += "\n"; Data statusAckData = new Data(new Name(interest.getName())); statusAckData.setContent(new Blob("Status acknowledged")); face.putData(statusAckData); }
public void onInterest(Name prefix, Interest interest, Face face, long interestFilterId, InterestFilter filter) { Console.Out.WriteLine("Data not found: " + interest.getName().toUri()); }
public void setInterestFilter(long interestFilterId, InterestFilter filter, OnInterestCallback onInterest, Face face) { ILOG.J2CsMapping.Collections.Collections.Add(table_, new InterestFilterTable.Entry(interestFilterId, filter, onInterest, face)); }
public void onInterest(Name prefix, Interest interest, Face face, long interestFilterId, InterestFilter filter) { Console.Out.WriteLine("Got interest with name: " + prefix.ToString()); }