Clio develop
The XRP Ledger API server.
Loading...
Searching...
No Matches
util::requests::WsConnection Class Referenceabstract

Interface for WebSocket connections. It is used to hide SSL and plain connections behind the same interface. More...

#include <WsConnection.hpp>

Inheritance diagram for util::requests::WsConnection:

Public Member Functions

virtual std::expected< std::string, RequestErrorread (boost::asio::yield_context yield, std::optional< std::chrono::steady_clock::duration > timeout=std::nullopt)=0
 Read a message from the WebSocket.
 
virtual std::optional< RequestErrorwrite (std::string const &message, boost::asio::yield_context yield, std::optional< std::chrono::steady_clock::duration > timeout=std::nullopt)=0
 Write a message to the WebSocket.
 
virtual std::optional< RequestErrorclose (boost::asio::yield_context yield, std::chrono::steady_clock::duration timeout=kDEFAULT_TIMEOUT)=0
 Close the WebSocket.
 

Static Public Attributes

static constexpr std::chrono::seconds kDEFAULT_TIMEOUT {5}
 

Detailed Description

Interface for WebSocket connections. It is used to hide SSL and plain connections behind the same interface.

Note
WsConnection must not be destroyed while there are pending asynchronous operations on it.

Member Function Documentation

◆ close()

virtual std::optional< RequestError > util::requests::WsConnection::close ( boost::asio::yield_context yield,
std::chrono::steady_clock::duration timeout = kDEFAULT_TIMEOUT )
pure virtual

Close the WebSocket.

Parameters
yieldyield context
timeouttimeout for the operation
Returns
Error if any

Implemented in util::requests::impl::WsConnectionImpl< StreamType >.

◆ read()

virtual std::expected< std::string, RequestError > util::requests::WsConnection::read ( boost::asio::yield_context yield,
std::optional< std::chrono::steady_clock::duration > timeout = std::nullopt )
pure virtual

Read a message from the WebSocket.

Parameters
yieldyield context
timeouttimeout for the operation
Returns
Message or error

Implemented in util::requests::impl::WsConnectionImpl< StreamType >.

◆ write()

virtual std::optional< RequestError > util::requests::WsConnection::write ( std::string const & message,
boost::asio::yield_context yield,
std::optional< std::chrono::steady_clock::duration > timeout = std::nullopt )
pure virtual

Write a message to the WebSocket.

Parameters
messagemessage to write
yieldyield context
timeouttimeout for the operation
Returns
Error if any

Implemented in util::requests::impl::WsConnectionImpl< StreamType >.

Member Data Documentation

◆ kDEFAULT_TIMEOUT

std::chrono::seconds util::requests::WsConnection::kDEFAULT_TIMEOUT {5}
staticconstexpr

Default timeout for connecting


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