Clio develop
The XRP Ledger API server.
Loading...
Searching...
No Matches
web::ng::impl::WsConnection< StreamType > Class Template Reference
Inheritance diagram for web::ng::impl::WsConnection< StreamType >:
Collaboration diagram for web::ng::impl::WsConnection< StreamType >:

Public Member Functions

 WsConnection (boost::asio::ip::tcp::socket socket, std::string ip, boost::beast::flat_buffer buffer, boost::beast::http::request< boost::beast::http::string_body > initialRequest, util::TagDecoratorFactory const &tagDecoratorFactory)
 
 WsConnection (boost::asio::ip::tcp::socket socket, std::string ip, boost::beast::flat_buffer buffer, boost::asio::ssl::context &sslContext, boost::beast::http::request< boost::beast::http::string_body > initialRequest, util::TagDecoratorFactory const &tagDecoratorFactory)
 
std::optional< Error > performHandshake (boost::asio::yield_context yield)
 
bool wasUpgraded () const override
 Whether the connection was upgraded. Upgraded connections are websocket connections.
 
std::optional< Error > sendBuffer (boost::asio::const_buffer buffer, boost::asio::yield_context yield) override
 
void setTimeout (std::chrono::steady_clock::duration newTimeout) override
 Get the timeout for send, receive, and close operations. For WebSocket connections, this is the ping interval.
 
std::optional< Error > send (Response response, boost::asio::yield_context yield) override
 Send a response to the client.
 
std::expected< Request, Error > receive (boost::asio::yield_context yield) override
 Receive a request from the client.
 
void close (boost::asio::yield_context yield) override
 Gracefully close the connection.
 
- Public Member Functions inherited from web::ng::impl::WsConnectionBase
 Connection (std::string ip, boost::beast::flat_buffer buffer, util::TagDecoratorFactory const &tagDecoratorFactory)
 Construct a new Connection object.
 
- Public Member Functions inherited from web::ng::Connection
 Connection (std::string ip, boost::beast::flat_buffer buffer, util::TagDecoratorFactory const &tagDecoratorFactory)
 Construct a new Connection object.
 
- Public Member Functions inherited from util::Taggable
 Taggable (Taggable &&)=default
 
Taggableoperator= (Taggable &&)=default
 
BaseTagDecorator const & tag () const
 Getter for tag decorator.
 

Additional Inherited Members

- Static Public Attributes inherited from web::ng::Connection
static constexpr std::chrono::steady_clock::duration kDEFAULT_TIMEOUT = std::chrono::seconds{11}
 The default timeout for send, receive, and close operations.
 
- Protected Member Functions inherited from util::Taggable
 Taggable (util::TagDecoratorFactory const &tagFactory)
 New Taggable from a specified factory.
 
- Protected Attributes inherited from web::ng::Connection
boost::beast::flat_buffer buffer_
 

Member Function Documentation

◆ close()

template<typename StreamType >
void web::ng::impl::WsConnection< StreamType >::close ( boost::asio::yield_context yield)
inlineoverridevirtual

Gracefully close the connection.

Parameters
yieldThe yield context.

Implements web::ng::Connection.

◆ receive()

template<typename StreamType >
std::expected< Request, Error > web::ng::impl::WsConnection< StreamType >::receive ( boost::asio::yield_context yield)
inlineoverridevirtual

Receive a request from the client.

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

Implements web::ng::Connection.

◆ send()

template<typename StreamType >
std::optional< Error > web::ng::impl::WsConnection< StreamType >::send ( Response response,
boost::asio::yield_context yield )
inlineoverridevirtual

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.

Implements web::ng::Connection.

◆ sendBuffer()

template<typename StreamType >
std::optional< Error > web::ng::impl::WsConnection< StreamType >::sendBuffer ( boost::asio::const_buffer buffer,
boost::asio::yield_context yield )
inlineoverridevirtual

◆ setTimeout()

template<typename StreamType >
void web::ng::impl::WsConnection< StreamType >::setTimeout ( std::chrono::steady_clock::duration newTimeout)
inlineoverridevirtual

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

Parameters
newTimeoutThe new timeout to set.

Implements web::ng::Connection.

◆ wasUpgraded()

template<typename StreamType >
bool web::ng::impl::WsConnection< StreamType >::wasUpgraded ( ) const
inlineoverridevirtual

Whether the connection was upgraded. Upgraded connections are websocket connections.

Returns
true if the connection was upgraded.

Implements web::ng::ConnectionMetadata.


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