SPSP
Simple publish-subscribe protocol. Connects low power IoT clients to MQTT.
All Classes Files Functions Variables Typedefs Enumerations
local_broker.hpp
Go to the documentation of this file.
1 
10 #pragma once
11 
12 #include <mutex>
13 #include <string>
14 
15 #include "spsp/layers.hpp"
16 #include "spsp/node.hpp"
17 #include "spsp/wildcard_trie.hpp"
18 
19 namespace SPSP::FarLayers::LocalBroker
20 {
26  class LocalBroker : public IFarLayer
27  {
28  std::mutex m_mutex;
30  std::string m_topicPrefix;
31 
32  public:
38  LocalBroker(const std::string topicPrefix = "spsp");
39 
44  ~LocalBroker();
45 
55  bool publish(const std::string& src, const std::string& topic,
56  const std::string& payload);
57 
67  bool subscribe(const std::string& topic);
68 
78  bool unsubscribe(const std::string& topic);
79  };
80 } // namespace SPSP::FarLayers::LocalBroker
SPSP::FarLayers::LocalBroker::LocalBroker
Local broker far layer.
Definition: local_broker.hpp:26
SPSP::FarLayers::LocalBroker::LocalBroker::LocalBroker
LocalBroker(const std::string topicPrefix="spsp")
Constructs a new local broker object.
SPSP::IFarLayer
Interface for far layer.
Definition: layers.hpp:83
node.hpp
Node interface for SPSP.
layers.hpp
Local and far layers for SPSP.
SPSP::FarLayers::LocalBroker::LocalBroker::~LocalBroker
~LocalBroker()
Destroys local broker layer object.
SPSP::FarLayers::LocalBroker::LocalBroker::unsubscribe
bool unsubscribe(const std::string &topic)
Unsubscribes from given topic.
SPSP::FarLayers::LocalBroker::LocalBroker::publish
bool publish(const std::string &src, const std::string &topic, const std::string &payload)
Publishes message coming from node.
SPSP::FarLayers::LocalBroker::LocalBroker::subscribe
bool subscribe(const std::string &topic)
Subscribes to given topic.
SPSP::WildcardTrie< bool >
wildcard_trie.hpp
Trie implementation with wildcard support.