def main(): # Silence the warning from Interest wire encode. Interest.setDefaultCanBePrefix(True) # The default Face will connect using a Unix socket, or to "localhost". face = Face() prefix = Namespace("/ndn/test/status") prefix.setFace(face) enabled = [True] # This is called to print the content after it is re-assembled from segments. def onGeneralizedObject(contentMetaInfo, objectNamespace): dump("Got generalized object", objectNamespace.name, ", content-type", contentMetaInfo.contentType, ":", str(objectNamespace.obj)) enabled[0] = False handler = GeneralizedObjectHandler(prefix, onGeneralizedObject) # Allow one component after the prefix for the <version>. handler.setNComponentsAfterObjectNamespace(1) # In objectNeeded, set mustBeFresh == true so we avoid expired cached data. prefix.objectNeeded(True) # Loop calling processEvents until a callback sets enabled[0] = False. while enabled[0]: face.processEvents() # We need to sleep for a few milliseconds so we don't use 100% of the CPU. time.sleep(0.01)