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::Name & | getApplicationDataPrefix () |
| 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... | |
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.
|
inline |
Create a ChannelDiscovery with the given parameters and begin listening for channel announcements.
| applicationDataPrefix | The 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 . |
| channelListFilePath | The 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. |
| applicationBroadcastPrefix | The name prefix for ChonoSync broadcast interests and sync updates. For example, /ndn/broadcast/flume/discovery . |
| face | The Face for calling registerPrefix and expressInterest. The Face object must remain valid for the life of this ChannelDiscovery object. |
| keyChain | To sign a data packet containing a sync state message, this calls keyChain.sign(data, certificateName). |
| certificateName | The certificate name of the key to use for signing a data packet containing a sync state message. |
| syncLifetime | The interest lifetime in milliseconds for sending sync interests, for example 5000.0. |
| onReceivedChannelList | On 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. |
| 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. |
|
inline |
Add the channel to this user's list of channels and publish the new list.
| channel | The new channel name. If already in the list of channels, this does nothing. |
|
inline |
Get the applicationDataPrefix given to the constructor.
|
inline |
Get the channel list for the user.
To get the channel list for this user, call getChannelList(getApplicationDataPrefix()).
| userPrefix | The user's application data prefix. |
|
inline |
Get the list of prefixes for other users, which can be used in getChannelList(userPrefix).
|
inline |
Remove the channel from this user's list of channels and publish the new list.
| channel | The name of the channel to remove. If already removed from the list of channels, this does nothing. |
1.8.6