Flyby SDK v1.0.2
Loading...
Searching...
No Matches
publisher.h
Go to the documentation of this file.
1
8
9#pragma once
10
11#include <functional>
12
15
16namespace flyby {
22 public:
26 [[nodiscard]] virtual std::shared_ptr<PublishObservable> on_success(const std::function<void()>& fn) = 0;
27
31 [[nodiscard]] virtual std::shared_ptr<PublishObservable> on_failure(const std::function<void()>& fn) = 0;
32 };
33
40 class Publisher {
41 public:
48 static std::shared_ptr<Publisher> create(const std::string& client_id);
49
50 virtual ~Publisher() = default;
51
57 virtual bool is_connected() = 0;
58
66 virtual void publish(
67 const std::string& topic,
68 const std::string& message,
69 const std::string& source = std::string()
70 ) = 0;
71
78 virtual void publish(const std::string& topic, Message& message) = 0;
79
87 [[nodiscard]] virtual std::shared_ptr<PublishObservable> publish_observe(
88 const std::string& topic,
89 const std::string& message
90 ) = 0;
91 };
92} // namespace flyby
A message that is sent across the message bus.
Definition message.h:167
General observable interface.
Definition observable.h:20
Observable for publishing status on the message bus.
Definition publisher.h:21
virtual std::shared_ptr< PublishObservable > on_failure(const std::function< void()> &fn)=0
Handles failure.
virtual std::shared_ptr< PublishObservable > on_success(const std::function< void()> &fn)=0
Handles success.
The class used for publishing to the message bus.
Definition publisher.h:40
static std::shared_ptr< Publisher > create(const std::string &client_id)
Creates a publisher handler.
virtual void publish(const std::string &topic, Message &message)=0
Publish a message to the message bus.
virtual void publish(const std::string &topic, const std::string &message, const std::string &source=std::string())=0
Publish a message to the message bus.
virtual bool is_connected()=0
Check if the publisher is connected.
virtual std::shared_ptr< PublishObservable > publish_observe(const std::string &topic, const std::string &message)=0
Publish a message to the message bus.