Clio  develop
The XRP Ledger API server.
Loading...
Searching...
No Matches
Unsubscribe.hpp
1#pragma once
2
3#include "feed/SubscriptionManagerInterface.hpp"
4#include "feed/Types.hpp"
5#include "rpc/common/SpecBackend.hpp"
6#include "rpc/common/Types.hpp"
7
8#include <rpcspec/handlers/unsubscribe/Types.hpp>
9#include <xrpl/protocol/AccountID.h>
10#include <xrpl/protocol/UintTypes.h>
11
12#include <expected>
13#include <memory>
14#include <vector>
15
16namespace rpc {
17
25
26class UnsubscribeHandler : public rpc::HandlerFor<rpc::spec::handlers::unsubscribe::Input> {
27 std::shared_ptr<feed::SubscriptionManagerInterface> subscriptions_;
28
29public:
33 using OrderBook = rpc::spec::handlers::unsubscribe::OrderBook;
34
38 using StreamType = rpc::spec::handlers::unsubscribe::StreamType;
39
48
54 UnsubscribeHandler(std::shared_ptr<feed::SubscriptionManagerInterface> const& subscriptions);
55
63 [[nodiscard]] Result
64 process(Input const& input, Context const& ctx) const;
65
66private:
67 void
68 unsubscribeFromStreams(
69 std::vector<StreamType> const& streams,
70 feed::SubscriberSharedPtr const& session
71 ) const;
72
73 void
74 unsubscribeFromAccounts(
75 std::vector<xrpl::AccountID> const& accounts,
76 feed::SubscriberSharedPtr const& session
77 ) const;
78
79 void
80 unsubscribeFromProposedAccounts(
81 std::vector<xrpl::AccountID> const& accountsProposed,
82 feed::SubscriberSharedPtr const& session
83 ) const;
84
85 void
86 unsubscribeFromBooks(
87 std::vector<OrderBook> const& books,
88 feed::SubscriberSharedPtr const& session
89 ) const;
90
91 void
92 unsubscribeFromMPTIssuances(
93 std::vector<xrpl::MPTID> const& mptIssuanceIDs,
94 feed::SubscriberSharedPtr const& session
95 ) const;
96};
97
98} // namespace rpc
rpc::spec::handlers::unsubscribe::OrderBook OrderBook
A struct to hold one order book.
Definition Unsubscribe.hpp:33
VoidOutput Output
The command has no output data.
Definition Unsubscribe.hpp:43
HandlerReturnType< Output > Result
The result type of the command: either the Output or an error status.
Definition Unsubscribe.hpp:47
UnsubscribeHandler(std::shared_ptr< feed::SubscriptionManagerInterface > const &subscriptions)
Construct a new BaseUnsubscribeHandler object.
Definition Unsubscribe.cpp:18
Result process(Input const &input, Context const &ctx) const
Process the Unsubscribe command.
Definition Unsubscribe.cpp:26
rpc::spec::handlers::unsubscribe::StreamType StreamType
A subscribable stream type.
Definition Unsubscribe.hpp:38
std::shared_ptr< Subscriber > SubscriberSharedPtr
Shared ownership pointer to a subscriber.
Definition Types.hpp:22
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:63
spec::HandlerFor< InputT, boost::json::value > HandlerFor
The spec-driven base every typed handler inherits.
Definition SpecBackend.hpp:24
Context of an RPC call.
Definition Types.hpp:102
An empty type used as Output for handlers than don't actually produce output.
Definition Types.hpp:97