onContentSet
     (Namespace nameSpace, Namespace contentNamespace, long callbackId)
 {
     if (contentNamespace.getName().size() == namespace_.getName().size() + 2 &&
         contentNamespace.getName()[-2].equals(fileMarker_))
     {
         var version = contentNamespace.getName()[-1];
         if (version.isVersion())
         {
             // Got the file marker for the version such as
             // <namespace>/%C1.FS.file/<version>. Fetch the segmented content.
             var segmentedContent = new SegmentedContent(namespace_[version]);
             segmentedContent.start();
         }
     }
     else if (contentNamespace.getName().size() == namespace_.getName().size() + 1 &&
              contentNamespace.getName()[-1].isVersion())
     {
         // We got the assembled content from the SegmentedContent handler.
         if (onVersionContentSet_ != null)
         {
             onVersionContentSet_(this, contentNamespace, (Blob)contentNamespace.getContent());
         }
     }
 }
Beispiel #2
0
        onContentSet
            (Namespace nameSpace, Namespace contentNamespace, long callbackId)
        {
            if (!(contentNamespace.getName().size() >= namespace_.getName().size() + 1 &&
                  contentNamespace.getName()[namespace_.getName().size()].isSegment()))
            {
                // Not a segment, ignore.
                return;
            }

            // TODO: Use the Namespace mechanism to validate the Data packet.

            var metaInfo = contentNamespace.getData().getMetaInfo();

            if (metaInfo.getFinalBlockId().getValue().size() > 0 &&
                metaInfo.getFinalBlockId().isSegment())
            {
                finalSegmentNumber_ = metaInfo.getFinalBlockId().toSegment();
            }

            // Report as many segments as possible where the node already has content.
            while (true)
            {
                var nextSegmentNumber = maxRetrievedSegmentNumber_ + 1;
                var nextSegment       = debugGetRightmostLeaf
                                            (namespace_[Name.Component.fromSegment(nextSegmentNumber)]);
                if (nextSegment.getContent() == null)
                {
                    break;
                }

                maxRetrievedSegmentNumber_ = nextSegmentNumber;
                fireOnSegment(nextSegment);

                if (finalSegmentNumber_ >= 0 && nextSegmentNumber == finalSegmentNumber_)
                {
                    // Finished.
                    fireOnSegment(null);
                    return;
                }
            }

            if (finalSegmentNumber_ < 0 && !didRequestFinalSegment_)
            {
                didRequestFinalSegment_ = true;
                // Try to determine the final segment now.
                var interestTemplate = new Interest();
                interestTemplate.setInterestLifetimeMilliseconds(4000.0);
                interestTemplate.setChildSelector(1);
                namespace_.expressInterest(interestTemplate);
            }

            requestNewSegments(interestPipelineSize_);
        }