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

A class representing a connection to a client. More...

#include <Connection.hpp>

Inheritance diagram for web::ng::Connection:
Collaboration diagram for web::ng::Connection:

Public Member Functions

 Connection (std::string ip, boost::beast::flat_buffer buffer, util::TagDecoratorFactory const &tagDecoratorFactory)
 Construct a new Connection object.
 
virtual void setTimeout (std::chrono::steady_clock::duration newTimeout)=0
 Get the timeout for send, receive, and close operations. For WebSocket connections, this is the ping interval.
 
virtual std::optional< Error > send (Response response, boost::asio::yield_context yield)=0
 Send a response to the client.
 
virtual std::expected< Request, Error > receive (boost::asio::yield_context yield)=0
 Receive a request from the client.
 
virtual void close (boost::asio::yield_context yield)=0
 Gracefully close the connection.
 
- Public Member Functions inherited from util::Taggable
 Taggable (Taggable &&)=default
 
Taggableoperator= (Taggable &&)=default
 
BaseTagDecorator const & tag () const
 Getter for tag decorator.
 

Static Public Attributes

static constexpr std::chrono::steady_clock::duration kDEFAULT_TIMEOUT = std::chrono::seconds{11}
 The default timeout for send, receive, and close operations.
 

Protected Attributes

boost::beast::flat_buffer buffer_
 

Additional Inherited Members

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

Detailed Description

A class representing a connection to a client.

Constructor & Destructor Documentation

◆ Connection()

web::ng::Connection::Connection ( std::string ip,
boost::beast::flat_buffer buffer,
util::TagDecoratorFactory const & tagDecoratorFactory )

Construct a new Connection object.

Parameters
ipThe client ip.
bufferThe buffer to use for reading and writing.
tagDecoratorFactoryThe factory for creating tag decorators.

Member Function Documentation

◆ close()

virtual void web::ng::Connection::close ( boost::asio::yield_context yield)
pure virtual

Gracefully close the connection.

Parameters
yieldThe yield context.

Implemented in web::ng::impl::HttpConnection< StreamType >, and web::ng::impl::WsConnection< StreamType >.

◆ receive()

virtual std::expected< Request, Error > web::ng::Connection::receive ( boost::asio::yield_context yield)
pure virtual

Receive a request from the client.

Parameters
yieldThe yield context.
Returns
The request if it was received or an error if the operation failed.

Implemented in web::ng::impl::HttpConnection< StreamType >, and web::ng::impl::WsConnection< StreamType >.

◆ send()

virtual std::optional< Error > web::ng::Connection::send ( Response response,
boost::asio::yield_context yield )
pure virtual

Send a response to the client.

Parameters
responseThe response to send.
yieldThe yield context.
Returns
An error if the operation failed or nullopt if it succeeded.

Implemented in web::ng::impl::HttpConnection< StreamType >, and web::ng::impl::WsConnection< StreamType >.

◆ setTimeout()

virtual void web::ng::Connection::setTimeout ( std::chrono::steady_clock::duration newTimeout)
pure virtual

Get the timeout for send, receive, and close operations. For WebSocket connections, this is the ping interval.

Parameters
newTimeoutThe new timeout to set.

Implemented in web::ng::impl::HttpConnection< StreamType >, and web::ng::impl::WsConnection< StreamType >.

Member Data Documentation

◆ kDEFAULT_TIMEOUT

std::chrono::steady_clock::duration web::ng::Connection::kDEFAULT_TIMEOUT = std::chrono::seconds{11}
staticconstexpr

The default timeout for send, receive, and close operations.

Note
This value should be higher than forwarding timeout to not disconnect clients if rippled is slow.

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