Main GossipSub implementation class. More...
#include <gossipsub.h>
Public Member Functions | |
| GossipSub (RatsClient &rats_client, const GossipSubConfig &config=GossipSubConfig()) | |
| Constructor. | |
| ~GossipSub () | |
| Destructor. | |
| bool | start () |
| Start the GossipSub service. | |
| void | stop () |
| Stop the GossipSub service. | |
| bool | is_running () const |
| Check if GossipSub is running. | |
| bool | subscribe (const std::string &topic) |
| Subscribe to a topic. | |
| bool | unsubscribe (const std::string &topic) |
| Unsubscribe from a topic. | |
| bool | is_subscribed (const std::string &topic) const |
| Check if subscribed to a topic. | |
| std::vector< std::string > | get_subscribed_topics () const |
| Get list of subscribed topics. | |
| bool | publish (const std::string &topic, const std::string &message) |
| Publish a message to a topic. | |
| bool | publish (const std::string &topic, const nlohmann::json &message) |
| Publish a JSON message to a topic. | |
| void | set_message_validator (const std::string &topic, MessageValidator validator) |
| Set message validator for a topic. | |
| void | set_message_handler (const std::string &topic, MessageHandler handler) |
| Set message handler for a topic. | |
| void | set_peer_joined_handler (const std::string &topic, PeerJoinedHandler handler) |
| Set peer joined handler for a topic. | |
| void | set_peer_left_handler (const std::string &topic, PeerLeftHandler handler) |
| Set peer left handler for a topic. | |
| std::vector< std::string > | get_topic_peers (const std::string &topic) const |
| Get peers subscribed to a topic. | |
| std::vector< std::string > | get_mesh_peers (const std::string &topic) const |
| Get mesh peers for a topic. | |
| double | get_peer_score (const std::string &peer_id) const |
| Get peer score. | |
| nlohmann::json | get_statistics () const |
| Get GossipSub statistics. | |
| nlohmann::json | get_cache_statistics () const |
| Get message cache statistics. | |
Friends | |
| class | RatsClient |
Main GossipSub implementation class.
Definition at line 167 of file gossipsub.h.
|
explicit |
Constructor.
| rats_client | Reference to the RatsClient instance |
| config | GossipSub configuration |
| librats::GossipSub::~GossipSub | ( | ) |
Destructor.
| nlohmann::json librats::GossipSub::get_cache_statistics | ( | ) | const |
Get message cache statistics.
| std::vector< std::string > librats::GossipSub::get_mesh_peers | ( | const std::string & | topic | ) | const |
Get mesh peers for a topic.
| topic | Topic name |
| double librats::GossipSub::get_peer_score | ( | const std::string & | peer_id | ) | const |
| nlohmann::json librats::GossipSub::get_statistics | ( | ) | const |
Get GossipSub statistics.
| std::vector< std::string > librats::GossipSub::get_subscribed_topics | ( | ) | const |
Get list of subscribed topics.
| std::vector< std::string > librats::GossipSub::get_topic_peers | ( | const std::string & | topic | ) | const |
Get peers subscribed to a topic.
| topic | Topic name |
| bool librats::GossipSub::is_running | ( | ) | const |
Check if GossipSub is running.
| bool librats::GossipSub::is_subscribed | ( | const std::string & | topic | ) | const |
Check if subscribed to a topic.
| topic | Topic name to check |
| bool librats::GossipSub::publish | ( | const std::string & | topic, |
| const nlohmann::json & | message | ||
| ) |
Publish a JSON message to a topic.
| topic | Topic to publish to |
| message | JSON message content |
| bool librats::GossipSub::publish | ( | const std::string & | topic, |
| const std::string & | message | ||
| ) |
Publish a message to a topic.
| topic | Topic to publish to |
| message | Message content |
| void librats::GossipSub::set_message_handler | ( | const std::string & | topic, |
| MessageHandler | handler | ||
| ) |
Set message handler for a topic.
| topic | Topic name |
| handler | Message handler function |
| void librats::GossipSub::set_message_validator | ( | const std::string & | topic, |
| MessageValidator | validator | ||
| ) |
Set message validator for a topic.
| topic | Topic name (empty for all topics) |
| validator | Validation function |
| void librats::GossipSub::set_peer_joined_handler | ( | const std::string & | topic, |
| PeerJoinedHandler | handler | ||
| ) |
Set peer joined handler for a topic.
| topic | Topic name |
| handler | Peer joined handler function |
| void librats::GossipSub::set_peer_left_handler | ( | const std::string & | topic, |
| PeerLeftHandler | handler | ||
| ) |
Set peer left handler for a topic.
| topic | Topic name |
| handler | Peer left handler function |
| bool librats::GossipSub::start | ( | ) |
Start the GossipSub service.
| void librats::GossipSub::stop | ( | ) |
Stop the GossipSub service.
| bool librats::GossipSub::subscribe | ( | const std::string & | topic | ) |
Subscribe to a topic.
| topic | Topic name to subscribe to |
| bool librats::GossipSub::unsubscribe | ( | const std::string & | topic | ) |
Unsubscribe from a topic.
| topic | Topic name to unsubscribe from |
|
friend |
Definition at line 168 of file gossipsub.h.