All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
Public Types | Static Public Member Functions | List of all members
ndntools::GeneralizedContent Class Reference

GeneralizedContent has the static publish and fetch methods which fetches meta info and segmented content. More...

#include <generalized-content.hpp>

Inheritance diagram for ndntools::GeneralizedContent:

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...
 

Detailed Description

GeneralizedContent has the static publish and fetch methods which fetches meta info and segmented content.

See the methods for more detail.

Note
The support for GeneralizedContent is experimental and the API is not finalized.

Member Function Documentation

void ndntools::GeneralizedContent::fetch ( ndn::Face face,
const ndn::Name prefix,
ndn::KeyChain validatorKeyChain,
const OnComplete &  onComplete,
const OnError &  onError,
ndn::Milliseconds  interestLifetimeMilliseconds = 4000.0 
)
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 .

Parameters
faceThis calls face.expressInterest to fetch the _meta info and segments.
prefixThe prefix of the Data packets before the _meta or segment number components.
validatorKeyChainWhen 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.
onCompleteWhen 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.
onErrorCall 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.
void ndntools::GeneralizedContent::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 
)
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.

Parameters
contentCacheThis 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.
prefixThe Name prefix for the published Data packets.
freshnessPeriodThe freshness period in milliseconds for the packets.
signingKeyChainThis calls signingKeyChain.sign to sign the packets.
signingCertificateNameThe certificate name of the key used in signingKeyChain.sign .
metaInfoThe ContentMetaInfo for the _meta packet.
contentThe content which is segmented and published. If metaInfo.getHasSegments() is false then this is ignored.
contentSegmentSizeThe 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.

The documentation for this class was generated from the following files: