3#include "data/AmendmentCenterInterface.hpp"
4#include "data/BackendInterface.hpp"
5#include "feed/SubscriptionManagerInterface.hpp"
6#include "feed/Types.hpp"
7#include "rpc/common/Types.hpp"
9#include <boost/asio/spawn.hpp>
10#include <boost/json/array.hpp>
11#include <boost/json/conversion.hpp>
12#include <boost/json/object.hpp>
13#include <boost/json/value.hpp>
14#include <rpcspec/HandlerFor.hpp>
15#include <rpcspec/handlers/subscribe/Types.hpp>
16#include <xrpl/protocol/AccountID.h>
32class SubscribeHandler :
public rpc::spec::HandlerFor<rpc::spec::handlers::subscribe::Input> {
33 std::shared_ptr<BackendInterface> sharedPtrBackend_;
34 std::shared_ptr<data::AmendmentCenterInterface const> amendmentCenter_;
35 std::shared_ptr<feed::SubscriptionManagerInterface> subscriptions_;
44 std::optional<boost::json::object> ledger;
48 std::optional<boost::json::array> offers;
50 std::optional<boost::json::array> asks;
52 std::optional<boost::json::array> bids;
58 using OrderBook = rpc::spec::handlers::subscribe::OrderBook;
63 using StreamType = rpc::spec::handlers::subscribe::StreamType;
75 std::shared_ptr<BackendInterface> sharedPtrBackend,
76 std::shared_ptr<data::AmendmentCenterInterface const>
const& amendmentCenter,
77 std::shared_ptr<feed::SubscriptionManagerInterface>
const& subscriptions
91 [[nodiscard]] boost::json::object
93 boost::asio::yield_context yield,
94 std::vector<StreamType>
const& streams,
95 feed::SubscriberSharedPtr
const& session
100 std::vector<xrpl::AccountID>
const& accounts,
101 feed::SubscriberSharedPtr
const& session
105 subscribeToAccountsProposed(
106 std::vector<xrpl::AccountID>
const& accounts,
107 feed::SubscriberSharedPtr
const& session
112 std::vector<OrderBook>
const& books,
113 feed::SubscriberSharedPtr
const& session,
114 boost::asio::yield_context yield,
125 tag_invoke(boost::json::value_from_tag, boost::json::value& jv,
Output const& output);
rpc::spec::handlers::subscribe::StreamType StreamType
A subscribable stream type.
Definition Subscribe.hpp:63
friend void tag_invoke(boost::json::value_from_tag, boost::json::value &jv, Output const &output)
Convert output to json value.
Definition Subscribe.cpp:194
Result process(Input const &input, Context const &ctx) const
Process the Subscribe command.
Definition Subscribe.cpp:44
SubscribeHandler(std::shared_ptr< BackendInterface > sharedPtrBackend, std::shared_ptr< data::AmendmentCenterInterface const > const &amendmentCenter, std::shared_ptr< feed::SubscriptionManagerInterface > const &subscriptions)
Construct a new BaseSubscribeHandler object.
Definition Subscribe.cpp:32
rpc::spec::handlers::subscribe::OrderBook OrderBook
A struct to hold the data for one order book.
Definition Subscribe.hpp:58
This namespace contains all the RPC logic and handlers.
Definition AMMHelpers.cpp:17
std::expected< OutputType, Status > HandlerReturnType
Return type for each individual handler.
Definition Types.hpp:61
Context of an RPC call.
Definition Types.hpp:98
A struct to hold the output data of the command.
Definition Subscribe.hpp:41