Clio develop
The XRP Ledger API server.
Loading...
Searching...
No Matches
SubscriptionContextInterface.hpp
1//------------------------------------------------------------------------------
2/*
3 This file is part of clio: https://github.com/XRPLF/clio
4 Copyright (c) 2024, the clio developers.
5
6 Permission to use, copy, modify, and distribute this software for any
7 purpose with or without fee is hereby granted, provided that the above
8 copyright notice and this permission notice appear in all copies.
9
10 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17*/
18//==============================================================================
19
20#pragma once
21
22#include "util/Taggable.hpp"
23
24#include <boost/signals2/signal.hpp>
25#include <boost/signals2/variadic_signal.hpp>
26
27#include <cstdint>
28#include <functional>
29#include <memory>
30#include <string>
31
32namespace web {
33
40public:
45
51 virtual void
52 send(std::shared_ptr<std::string> message) = 0;
53
57 using OnDisconnectSlot = std::function<void(SubscriptionContextInterface*)>;
58
64 virtual void
66
71 virtual void
72 setApiSubversion(uint32_t value) = 0;
73
79 virtual uint32_t
80 apiSubversion() const = 0;
81};
82
86using SubscriptionContextPtr = std::shared_ptr<SubscriptionContextInterface>;
87
88} // namespace web
A base class that allows attaching a tag decorator to a subclass.
Definition Taggable.hpp:240
Taggable(util::TagDecoratorFactory const &tagFactory)
New Taggable from a specified factory.
Definition Taggable.hpp:250
An interface to provide connection functionality for subscriptions.
Definition SubscriptionContextInterface.hpp:39
std::function< void(SubscriptionContextInterface *)> OnDisconnectSlot
Alias for on disconnect slot.
Definition SubscriptionContextInterface.hpp:57
virtual void send(std::shared_ptr< std::string > message)=0
Send message to the client.
virtual uint32_t apiSubversion() const =0
Get the API subversion.
virtual void onDisconnect(OnDisconnectSlot const &slot)=0
Connect a slot to onDisconnect connection signal.
virtual void setApiSubversion(uint32_t value)=0
Set the API subversion.
This namespace implements the web server and related components.
Definition Types.hpp:43
std::shared_ptr< SubscriptionContextInterface > SubscriptionContextPtr
An alias for shared pointer to a SubscriptionContextInterface.
Definition SubscriptionContextInterface.hpp:86