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

The ChannelDiscovery class uses ChronoSync to listen to the application's "discovery" channel for announcements of other channels. More...

#include <channel-discovery.hpp>

Public Types

enum  ErrorCode { REGISTER_FAILED = 1, INTEREST_TIMEOUT = 2 }
 
typedef
ndn::func_lib::function< void(ChannelDiscovery
&channelDiscovery, const
ndn::ptr_lib::shared_ptr
< ndn::Name > &userPrefix)> 
OnReceivedChannelList
 
typedef
ndn::func_lib::function< void(ErrorCode
errorCode, const std::string
&message)> 
OnError
 

Public Member Functions

 ChannelDiscovery (const ndn::Name &applicationDataPrefix, const std::string &channelListFilePath, const ndn::Name &applicationBroadcastPrefix, ndn::Face &face, ndn::KeyChain &keyChain, const ndn::Name &certificateName, ndn::Milliseconds syncLifetime, const OnReceivedChannelList &onReceivedChannelList, const OnError &onError)
 Create a ChannelDiscovery with the given parameters and begin listening for channel announcements. More...
 
void addChannel (const std::string &channel)
 Add the channel to this user's list of channels and publish the new list. More...
 
void removeChannel (const std::string &channel)
 Remove the channel from this user's list of channels and publish the new list. More...
 
const ndn::NamegetApplicationDataPrefix ()
 Get the applicationDataPrefix given to the constructor. More...
 
ndn::ptr_lib::shared_ptr
< std::vector< ndn::Name > > 
getOtherUserPrefixes ()
 Get the list of prefixes for other users, which can be used in getChannelList(userPrefix). More...
 
ndn::ptr_lib::shared_ptr
< std::vector< std::string > > 
getChannelList (const ndn::Name &userPrefix)
 Get the channel list for the user. More...
 

Detailed Description

The ChannelDiscovery class uses ChronoSync to listen to the application's "discovery" channel for announcements of other channels.

It maintains a list of the current channels created by each user and informs the application when a channel is added or removed.

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

Constructor & Destructor Documentation

ndntools::ChannelDiscovery::ChannelDiscovery ( const ndn::Name applicationDataPrefix,
const std::string &  channelListFilePath,
const ndn::Name applicationBroadcastPrefix,
ndn::Face face,
ndn::KeyChain keyChain,
const ndn::Name certificateName,
ndn::Milliseconds  syncLifetime,
const OnReceivedChannelList &  onReceivedChannelList,
const OnError &  onError 
)
inline

Create a ChannelDiscovery with the given parameters and begin listening for channel announcements.

Parameters
applicationDataPrefixThe name prefix for the Data packet from this user with the list of channels created by this user. For example, /ndn/edu/ucla/remap/peter/flume/discovery .
channelListFilePathThe file path to store the Data packet from this user with the list of channels created by this user. This is used for persistent storage between sessions. This will create the file if it doesn't exist.
applicationBroadcastPrefixThe name prefix for ChonoSync broadcast interests and sync updates. For example, /ndn/broadcast/flume/discovery .
faceThe Face for calling registerPrefix and expressInterest. The Face object must remain valid for the life of this ChannelDiscovery object.
keyChainTo sign a data packet containing a sync state message, this calls keyChain.sign(data, certificateName).
certificateNameThe certificate name of the key to use for signing a data packet containing a sync state message.
syncLifetimeThe interest lifetime in milliseconds for sending sync interests, for example 5000.0.
onReceivedChannelListOn receiving a channel list from another user, this calls onReceivedChannelList(channelDiscovery, userPrefix) where channelDiscovery is this ChannelDiscovery object and userPrefix is the Name of the user who updated the channel list. To get the new list, call channelDiscovery.getChannelList(*userPrefix). 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.

Member Function Documentation

void ndntools::ChannelDiscovery::addChannel ( const std::string &  channel)
inline

Add the channel to this user's list of channels and publish the new list.

Parameters
channelThe new channel name. If already in the list of channels, this does nothing.
const ndn::Name& ndntools::ChannelDiscovery::getApplicationDataPrefix ( )
inline

Get the applicationDataPrefix given to the constructor.

Returns
The applicationDataPrefix. You should not change this object.
ndn::ptr_lib::shared_ptr<std::vector<std::string> > ndntools::ChannelDiscovery::getChannelList ( const ndn::Name userPrefix)
inline

Get the channel list for the user.

To get the channel list for this user, call getChannelList(getApplicationDataPrefix()).

Parameters
userPrefixThe user's application data prefix.
Returns
A sorted copy of the user's channel list, or null if the userPrefix does not exist.
ndn::ptr_lib::shared_ptr<std::vector<ndn::Name> > ndntools::ChannelDiscovery::getOtherUserPrefixes ( )
inline

Get the list of prefixes for other users, which can be used in getChannelList(userPrefix).

Returns
An unsorted copy of the list of user prefix Names. This does not contain this user's getApplicationDataPrefix().
void ndntools::ChannelDiscovery::removeChannel ( const std::string &  channel)
inline

Remove the channel from this user's list of channels and publish the new list.

Parameters
channelThe name of the channel to remove. If already removed from the list of channels, this does nothing.

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