Clio develop
The XRP Ledger API server.
Loading...
Searching...
No Matches
web::ng::SubscriptionContext Class Reference

Implementation of SubscriptionContextInterface. More...

#include <SubscriptionContext.hpp>

Inheritance diagram for web::ng::SubscriptionContext:
Collaboration diagram for web::ng::SubscriptionContext:

Public Types

using ErrorHandler = std::function<bool(Error const&, Connection const&)>
 Error handler definition. Error handler returns true if connection should be closed false otherwise.
 
- Public Types inherited from web::SubscriptionContextInterface
using OnDisconnectSlot = std::function<void(SubscriptionContextInterface*)>
 Alias for on disconnect slot.
 

Public Member Functions

 SubscriptionContext (util::TagDecoratorFactory const &factory, impl::WsConnectionBase &connection, std::optional< size_t > maxSendQueueSize, boost::asio::yield_context yield, ErrorHandler errorHandler)
 Construct a new Subscription Context object.
 
void send (std::shared_ptr< std::string > message) override
 Send message to the client.
 
void onDisconnect (OnDisconnectSlot const &slot) override
 Connect a slot to onDisconnect connection signal.
 
void setApiSubversion (uint32_t value) override
 Set the API subversion.
 
uint32_t apiSubversion () const override
 Get the API subversion.
 
void disconnect (boost::asio::yield_context yield)
 Notify the context that related connection is disconnected and wait for all the task to complete.
 
- Public Member Functions inherited from web::SubscriptionContextInterface
- Public Member Functions inherited from util::Taggable
 Taggable (Taggable &&)=default
 
Taggableoperator= (Taggable &&)=default
 
BaseTagDecorator const & tag () const
 Getter for tag decorator.
 

Additional Inherited Members

- Protected Member Functions inherited from util::Taggable
 Taggable (util::TagDecoratorFactory const &tagFactory)
 New Taggable from a specified factory.
 

Detailed Description

Implementation of SubscriptionContextInterface.

Note
This class is designed to be used with SubscriptionManager. The class is safe to use from multiple threads. The method disconnect() must be called before the object is destroyed.

Constructor & Destructor Documentation

◆ SubscriptionContext()

web::ng::SubscriptionContext::SubscriptionContext ( util::TagDecoratorFactory const & factory,
impl::WsConnectionBase & connection,
std::optional< size_t > maxSendQueueSize,
boost::asio::yield_context yield,
ErrorHandler errorHandler )

Construct a new Subscription Context object.

Parameters
factoryThe tag decorator factory to use to init taggable.
connectionThe connection for which the context is created.
maxSendQueueSizeThe maximum size of the send queue. If the queue is full, the connection will be closed.
yieldThe yield context to spawn sending coroutines.
errorHandlerThe error handler.

Member Function Documentation

◆ apiSubversion()

uint32_t web::ng::SubscriptionContext::apiSubversion ( ) const
overridevirtual

Get the API subversion.

Returns
The API subversion.

Implements web::SubscriptionContextInterface.

◆ disconnect()

void web::ng::SubscriptionContext::disconnect ( boost::asio::yield_context yield)

Notify the context that related connection is disconnected and wait for all the task to complete.

Note
This method must be called before the object is destroyed.
Parameters
yieldThe yield context to wait for all the tasks to complete.

◆ onDisconnect()

void web::ng::SubscriptionContext::onDisconnect ( OnDisconnectSlot const & slot)
overridevirtual

Connect a slot to onDisconnect connection signal.

Parameters
slotThe slot to connect.

Implements web::SubscriptionContextInterface.

◆ send()

void web::ng::SubscriptionContext::send ( std::shared_ptr< std::string > message)
overridevirtual

Send message to the client.

Note
This method does nothing after disconnected() was called.
Parameters
messageThe message to send.

Implements web::SubscriptionContextInterface.

◆ setApiSubversion()

void web::ng::SubscriptionContext::setApiSubversion ( uint32_t value)
overridevirtual

Set the API subversion.

Parameters
valueThe value to set.

Implements web::SubscriptionContextInterface.


The documentation for this class was generated from the following files: