3#include "util/CoroutineGroup.hpp"
4#include "util/Taggable.hpp"
5#include "web/SubscriptionContextInterface.hpp"
6#include "web/ng/Connection.hpp"
7#include "web/ng/Error.hpp"
8#include "web/ng/impl/WsConnection.hpp"
10#include <boost/asio/any_io_executor.hpp>
11#include <boost/asio/spawn.hpp>
12#include <boost/signals2/variadic_signal.hpp>
36 std::reference_wrapper<impl::WsConnectionBase> connection_;
38 boost::asio::yield_context yield_;
42 std::atomic_bool disconnected_{
false};
43 std::atomic_bool gotError_{
false};
51 std::atomic_uint32_t apiSubversion_ = 0u;
64 impl::WsConnectionBase& connection,
65 boost::asio::yield_context yield,
78 send(std::shared_ptr<std::string> message)
override;
100 [[nodiscard]] uint32_t
CoroutineGroup is a helper class to manage a group of coroutines. It allows to spawn multiple corouti...
Definition CoroutineGroup.hpp:18
A factory for TagDecorator instantiation.
Definition Taggable.hpp:165
An interface to provide connection functionality for subscriptions.
Definition SubscriptionContextInterface.hpp:20
std::function< void(SubscriptionContextInterface *)> OnDisconnectSlot
Alias for on disconnect slot.
Definition SubscriptionContextInterface.hpp:35
A context of a WsBase connection for subscriptions.
Definition SubscriptionContext.hpp:20
A class representing a connection to a client.
Definition Connection.hpp:114
SubscriptionContext(util::TagDecoratorFactory const &factory, impl::WsConnectionBase &connection, boost::asio::yield_context yield, ErrorHandler errorHandler)
Construct a new Subscription Context object.
Definition SubscriptionContext.cpp:16
std::function< bool(Error const &, Connection const &)> ErrorHandler
Error handler definition. Error handler returns true if connection should be closed false otherwise.
Definition SubscriptionContext.hpp:33
void onDisconnect(OnDisconnectSlot const &slot) override
Connect a slot to onDisconnect connection signal.
Definition SubscriptionContext.cpp:56
void send(std::shared_ptr< std::string > message) override
Send message to the client.
Definition SubscriptionContext.cpp:36
void setApiSubversion(uint32_t value) override
Set the API subversion.
Definition SubscriptionContext.cpp:62
uint32_t apiSubversion() const override
Get the API subversion.
Definition SubscriptionContext.cpp:68
void disconnect(boost::asio::yield_context yield)
Notify the context that related connection is disconnected and wait for all the task to complete.
Definition SubscriptionContext.cpp:74