GeneralizedContent has the static publish and fetch methods which fetches meta info and segmented content. More...
#include <generalized-content.hpp>
Public Types | |
| enum | ErrorCode { INTEREST_TIMEOUT = 1, DATA_HAS_NO_SEGMENT = 2, SEGMENT_VERIFICATION_FAILED = 3, META_INFO_DECODING_FAILED = 4 } |
|
typedef ndn::func_lib::function< void(const ndn::ptr_lib::shared_ptr < ContentMetaInfo > &metaInfo, const ndn::Blob &content)> | OnComplete |
|
typedef ndn::func_lib::function< void(ErrorCode errorCode, const std::string &message)> | OnError |
Static Public Member Functions | |
| static void | publish (ndn::MemoryContentCache &contentCache, const ndn::Name &prefix, ndn::Milliseconds freshnessPeriod, ndn::KeyChain *signingKeyChain, const ndn::Name &signingCertificateName, const ContentMetaInfo &metaInfo, const ndn::Blob &content, size_t contentSegmentSize) |
| Use the contentCache to publish a Data packet named [prefix]/_meta whose content is the encoded metaInfo. More... | |
| static void | fetch (ndn::Face &face, const ndn::Name &prefix, ndn::KeyChain *validatorKeyChain, const OnComplete &onComplete, const OnError &onError, ndn::Milliseconds interestLifetimeMilliseconds=4000.0) |
| Initiate meta info and segmented content fetching. More... | |
GeneralizedContent has the static publish and fetch methods which fetches meta info and segmented content.
See the methods for more detail.
|
static |
Initiate meta info and segmented content fetching.
This first fetches and decodes <prefix>/_meta . If the ContentSize in the _meta info is not zero then also fetch segments such as <prefix>/%00 .
| face | This calls face.expressInterest to fetch the _meta info and segments. |
| prefix | The prefix of the Data packets before the _meta or segment number components. |
| validatorKeyChain | When a Data packet is received this calls validatorKeyChain->verifyData(data). If validation fails then abort fetching and call onError with SEGMENT_VERIFICATION_FAILED. This does not make a copy of the KeyChain; the object must remain valid while fetching. If validatorKeyChain is null, this does not validate the data packet. |
| onComplete | When all segments are received, call onComplete(metaInfo, content) where metaInfo is the decoded ContentMetaInfo object and content is the concatenation of the content of all the segments. However, if the metaInfo content size is zero, then this does not fetch segments and the content is null. 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. |
| onError | Call onError(errorCode, message) for timeout or an error processing segments. 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. |
| interestLifetimeMilliseconds | (optional) The Interest lifetime in milliseconds for fetching the _meta info and segments. If omitted, use the default value from the default Interest object. |
|
static |
Use the contentCache to publish a Data packet named [prefix]/_meta whose content is the encoded metaInfo.
If metaInfo.getHasSegments() is true then use the contentCache to publish the segments of the content.
| contentCache | This calls contentCache.add to add the Data packets. After this call, the MemoryContentCache must remain valid long enough to respond to Interest for the published Data packets. |
| prefix | The Name prefix for the published Data packets. |
| freshnessPeriod | The freshness period in milliseconds for the packets. |
| signingKeyChain | This calls signingKeyChain.sign to sign the packets. |
| signingCertificateName | The certificate name of the key used in signingKeyChain.sign . |
| metaInfo | The ContentMetaInfo for the _meta packet. |
| content | The content which is segmented and published. If metaInfo.getHasSegments() is false then this is ignored. |
| contentSegmentSize | The the number of bytes for each segment of the content. (This is is the size of the content in the segment Data packet, not the size of the entire segment Data packet with overhead.) The final segment may be smaller than this. If metaInfo.getHasSegments() is false then this is ignored. |
1.8.6