Clio  develop
The XRP Ledger API server.
Loading...
Searching...
No Matches
SubscriptionContext.hpp
1#pragma once
2
3#include "util/Taggable.hpp"
4#include "web/SubscriptionContextInterface.hpp"
5#include "web/interface/Concepts.hpp"
6#include "web/interface/ConnectionBase.hpp"
7
8#include <boost/signals2/variadic_signal.hpp>
9
10#include <atomic>
11#include <cstdint>
12#include <memory>
13#include <string>
14
15namespace web {
16
21 std::weak_ptr<ConnectionBase> connection_;
22 boost::signals2::signal<void(SubscriptionContextInterface*)> onDisconnect_;
29 std::atomic_uint32_t apiSubVersion_ = 0;
30
31public:
39 util::TagDecoratorFactory const& factory,
40 std::shared_ptr<ConnectionBase> connection
41 );
42
46 ~SubscriptionContext() override;
47
54 void
55 send(std::shared_ptr<std::string> message) override;
56
62 void
63 onDisconnect(OnDisconnectSlot const& slot) override;
64
69 void
70 setApiSubversion(uint32_t value) override;
71
77 uint32_t
78 apiSubversion() const override;
79};
80
81} // namespace web
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
void send(std::shared_ptr< std::string > message) override
Send message to the client.
Definition SubscriptionContext.cpp:28
SubscriptionContext(util::TagDecoratorFactory const &factory, std::shared_ptr< ConnectionBase > connection)
Construct a new Subscription Context object.
Definition SubscriptionContext.cpp:14
~SubscriptionContext() override
Destroy the Subscription Context object.
Definition SubscriptionContext.cpp:22
void setApiSubversion(uint32_t value) override
Set the API subversion.
Definition SubscriptionContext.cpp:41
void onDisconnect(OnDisconnectSlot const &slot) override
Connect a slot to onDisconnect connection signal.
Definition SubscriptionContext.cpp:35
uint32_t apiSubversion() const override
Get the API subversion.
Definition SubscriptionContext.cpp:47
This namespace implements the web server and related components.
Definition Types.hpp:24