xrpld
Loading...
Searching...
No Matches
xrpl::BaseWSPeer< Handler, Impl > Class Template Reference

Represents an active WebSocket connection. More...

#include <BaseWSPeer.h>

Inheritance diagram for xrpl::BaseWSPeer< Handler, Impl >:
Collaboration diagram for xrpl::BaseWSPeer< Handler, Impl >:

Public Member Functions

template<class Body, class Headers>
 BaseWSPeer (Port const &port, Handler &handler, boost::asio::executor const &executor, waitable_timer timer, endpoint_type remoteAddress, boost::beast::http::request< Body, Headers > &&request, beast::Journal journal)
void run () override
Port const & port () const override
http_request_type const & request () const override
boost::asio::ip::tcp::endpoint const & remoteEndpoint () const override
void send (std::shared_ptr< WSMsg > w) override
 Send a WebSockets message.
void close () override
void close (boost::beast::websocket::close_reason const &reason) override
void complete () override
 Indicate that the response is complete.
IOListios ()
 Return the IOList associated with the work.

Public Attributes

std::shared_ptr< void > appDefined

Protected Types

using clock_type = std::chrono::system_clock
using error_code = boost::system::error_code
using endpoint_type = boost::asio::ip::tcp::endpoint
using waitable_timer = boost::asio::basic_waitable_timer<clock_type>

Protected Member Functions

Impl & impl ()
void onWsHandshake (error_code const &ec)
void doWrite ()
void onWrite (error_code const &ec)
void onWriteFin (error_code const &ec)
void doRead ()
void onRead (error_code const &ec)
void onClose (error_code const &ec)
void startTimer ()
void cancelTimer ()
void onPing (error_code const &ec)
void onPingPong (boost::beast::websocket::frame_type kind, boost::beast::string_view payload)
void onTimer (error_code ec)
template<class String>
void fail (error_code ec, String const &what)

Protected Attributes

Port const & port_
Handler & handler_
endpoint_type remoteAddress_
beast::WrappedSink sink_
beast::Journal const j_
boost::asio::executor_work_guard< boost::asio::executor > work_
boost::asio::strand< boost::asio::executor > strand_

Private Member Functions

template<class = void>
void destroy ()

Private Attributes

http_request_type request_
boost::beast::multi_buffer rb_
boost::beast::multi_buffer wb_
std::list< std::shared_ptr< WSMsg > > wq_
bool doClose_ = false
 The socket has been closed, or will close after the next write finishes.
boost::beast::websocket::close_reason cr_
waitable_timer timer_
bool closeOnTimer_ = false
bool pingActive_ = false
boost::beast::websocket::ping_data payload_
error_code ec_
std::function< void(boost::beast::websocket::frame_type, boost::beast::string_view)> controlCallback_
IOListios_ = nullptr

Friends

class BasePeer< Handler, Impl >

Detailed Description

template<class Handler, class Impl>
class xrpl::BaseWSPeer< Handler, Impl >

Represents an active WebSocket connection.

Definition at line 26 of file BaseWSPeer.h.

Member Typedef Documentation

◆ clock_type

template<class Handler, class Impl>
using xrpl::BaseWSPeer< Handler, Impl >::clock_type = std::chrono::system_clock
protected

Definition at line 29 of file BaseWSPeer.h.

◆ error_code

template<class Handler, class Impl>
using xrpl::BaseWSPeer< Handler, Impl >::error_code = boost::system::error_code
protected

Definition at line 30 of file BaseWSPeer.h.

◆ endpoint_type

template<class Handler, class Impl>
using xrpl::BaseWSPeer< Handler, Impl >::endpoint_type = boost::asio::ip::tcp::endpoint
protected

Definition at line 31 of file BaseWSPeer.h.

◆ waitable_timer

template<class Handler, class Impl>
using xrpl::BaseWSPeer< Handler, Impl >::waitable_timer = boost::asio::basic_waitable_timer<clock_type>
protected

Definition at line 32 of file BaseWSPeer.h.

Constructor & Destructor Documentation

◆ BaseWSPeer()

template<class Handler, class Impl>
template<class Body, class Headers>
xrpl::BaseWSPeer< Handler, Impl >::BaseWSPeer ( Port const & port,
Handler & handler,
boost::asio::executor const & executor,
waitable_timer timer,
endpoint_type remoteAddress,
boost::beast::http::request< Body, Headers > && request,
beast::Journal journal )

Definition at line 155 of file BaseWSPeer.h.

Member Function Documentation

◆ run()

template<class Handler, class Impl>
void xrpl::BaseWSPeer< Handler, Impl >::run ( )
overridevirtual

Implements xrpl::WSSession.

Definition at line 172 of file BaseWSPeer.h.

◆ port()

template<class Handler, class Impl>
Port const & xrpl::BaseWSPeer< Handler, Impl >::port ( ) const
nodiscardoverridevirtual

Implements xrpl::WSSession.

Definition at line 74 of file BaseWSPeer.h.

◆ request()

template<class Handler, class Impl>
http_request_type const & xrpl::BaseWSPeer< Handler, Impl >::request ( ) const
nodiscardoverridevirtual

Implements xrpl::WSSession.

Definition at line 80 of file BaseWSPeer.h.

◆ remoteEndpoint()

template<class Handler, class Impl>
boost::asio::ip::tcp::endpoint const & xrpl::BaseWSPeer< Handler, Impl >::remoteEndpoint ( ) const
nodiscardoverridevirtual

Implements xrpl::WSSession.

Definition at line 86 of file BaseWSPeer.h.

◆ send()

template<class Handler, class Impl>
void xrpl::BaseWSPeer< Handler, Impl >::send ( std::shared_ptr< WSMsg > w)
overridevirtual

Send a WebSockets message.

Implements xrpl::WSSession.

Definition at line 197 of file BaseWSPeer.h.

◆ close() [1/2]

template<class Handler, class Impl>
void xrpl::BaseWSPeer< Handler, Impl >::close ( )
overridevirtual

Reimplemented from xrpl::BasePeer< Handler, Impl >.

Definition at line 219 of file BaseWSPeer.h.

◆ close() [2/2]

template<class Handler, class Impl>
void xrpl::BaseWSPeer< Handler, Impl >::close ( boost::beast::websocket::close_reason const & reason)
overridevirtual

Implements xrpl::WSSession.

Definition at line 226 of file BaseWSPeer.h.

◆ complete()

template<class Handler, class Impl>
void xrpl::BaseWSPeer< Handler, Impl >::complete ( )
overridevirtual

Indicate that the response is complete.

The handler should call this when it has completed writing the response.

Implements xrpl::WSSession.

Definition at line 250 of file BaseWSPeer.h.

◆ impl()

template<class Handler, class Impl>
Impl & xrpl::BaseWSPeer< Handler, Impl >::impl ( )
protected

Definition at line 105 of file BaseWSPeer.h.

◆ onWsHandshake()

template<class Handler, class Impl>
void xrpl::BaseWSPeer< Handler, Impl >::onWsHandshake ( error_code const & ec)
protected

Definition at line 259 of file BaseWSPeer.h.

◆ doWrite()

template<class Handler, class Impl>
void xrpl::BaseWSPeer< Handler, Impl >::doWrite ( )
protected

Definition at line 269 of file BaseWSPeer.h.

◆ onWrite()

template<class Handler, class Impl>
void xrpl::BaseWSPeer< Handler, Impl >::onWrite ( error_code const & ec)
protected

Definition at line 278 of file BaseWSPeer.h.

◆ onWriteFin()

template<class Handler, class Impl>
void xrpl::BaseWSPeer< Handler, Impl >::onWriteFin ( error_code const & ec)
protected

Definition at line 311 of file BaseWSPeer.h.

◆ doRead()

template<class Handler, class Impl>
void xrpl::BaseWSPeer< Handler, Impl >::doRead ( )
protected

Definition at line 332 of file BaseWSPeer.h.

◆ onRead()

template<class Handler, class Impl>
void xrpl::BaseWSPeer< Handler, Impl >::onRead ( error_code const & ec)
protected

Definition at line 345 of file BaseWSPeer.h.

◆ onClose()

template<class Handler, class Impl>
void xrpl::BaseWSPeer< Handler, Impl >::onClose ( error_code const & ec)
protected

Definition at line 361 of file BaseWSPeer.h.

◆ startTimer()

template<class Handler, class Impl>
void xrpl::BaseWSPeer< Handler, Impl >::startTimer ( )
protected

Definition at line 368 of file BaseWSPeer.h.

◆ cancelTimer()

template<class Handler, class Impl>
void xrpl::BaseWSPeer< Handler, Impl >::cancelTimer ( )
protected

Definition at line 394 of file BaseWSPeer.h.

◆ onPing()

template<class Handler, class Impl>
void xrpl::BaseWSPeer< Handler, Impl >::onPing ( error_code const & ec)
protected

Definition at line 408 of file BaseWSPeer.h.

◆ onPingPong()

template<class Handler, class Impl>
void xrpl::BaseWSPeer< Handler, Impl >::onPingPong ( boost::beast::websocket::frame_type kind,
boost::beast::string_view payload )
protected

Definition at line 420 of file BaseWSPeer.h.

◆ onTimer()

template<class Handler, class Impl>
void xrpl::BaseWSPeer< Handler, Impl >::onTimer ( error_code ec)
protected

Definition at line 441 of file BaseWSPeer.h.

◆ fail()

template<class Handler, class Impl>
template<class String>
void xrpl::BaseWSPeer< Handler, Impl >::fail ( error_code ec,
String const & what )
protected

Definition at line 471 of file BaseWSPeer.h.

◆ destroy()

template<class = void>
void xrpl::IOList::Work::destroy ( )
privateinherited

Definition at line 162 of file io_list.h.

◆ ios()

IOList & xrpl::IOList::Work::ios ( )
inherited

Return the IOList associated with the work.

Requirements: The call to IOList::emplace to create the work has already returned.

Definition at line 40 of file io_list.h.

◆ BasePeer< Handler, Impl >

template<class Handler, class Impl>
friend class BasePeer< Handler, Impl >
friend

Definition at line 471 of file BaseWSPeer.h.

Member Data Documentation

◆ request_

template<class Handler, class Impl>
http_request_type xrpl::BaseWSPeer< Handler, Impl >::request_
private

Definition at line 38 of file BaseWSPeer.h.

◆ rb_

template<class Handler, class Impl>
boost::beast::multi_buffer xrpl::BaseWSPeer< Handler, Impl >::rb_
private

Definition at line 39 of file BaseWSPeer.h.

◆ wb_

template<class Handler, class Impl>
boost::beast::multi_buffer xrpl::BaseWSPeer< Handler, Impl >::wb_
private

Definition at line 40 of file BaseWSPeer.h.

◆ wq_

template<class Handler, class Impl>
std::list<std::shared_ptr<WSMsg> > xrpl::BaseWSPeer< Handler, Impl >::wq_
private

Definition at line 41 of file BaseWSPeer.h.

◆ doClose_

template<class Handler, class Impl>
bool xrpl::BaseWSPeer< Handler, Impl >::doClose_ = false
private

The socket has been closed, or will close after the next write finishes.

Do not do any more writes, and don't try to close again.

Definition at line 45 of file BaseWSPeer.h.

◆ cr_

template<class Handler, class Impl>
boost::beast::websocket::close_reason xrpl::BaseWSPeer< Handler, Impl >::cr_
private

Definition at line 46 of file BaseWSPeer.h.

◆ timer_

template<class Handler, class Impl>
waitable_timer xrpl::BaseWSPeer< Handler, Impl >::timer_
private

Definition at line 47 of file BaseWSPeer.h.

◆ closeOnTimer_

template<class Handler, class Impl>
bool xrpl::BaseWSPeer< Handler, Impl >::closeOnTimer_ = false
private

Definition at line 48 of file BaseWSPeer.h.

◆ pingActive_

template<class Handler, class Impl>
bool xrpl::BaseWSPeer< Handler, Impl >::pingActive_ = false
private

Definition at line 49 of file BaseWSPeer.h.

◆ payload_

template<class Handler, class Impl>
boost::beast::websocket::ping_data xrpl::BaseWSPeer< Handler, Impl >::payload_
private

Definition at line 50 of file BaseWSPeer.h.

◆ ec_

template<class Handler, class Impl>
error_code xrpl::BaseWSPeer< Handler, Impl >::ec_
private

Definition at line 51 of file BaseWSPeer.h.

◆ controlCallback_

template<class Handler, class Impl>
std::function<void(boost::beast::websocket::frame_type, boost::beast::string_view)> xrpl::BaseWSPeer< Handler, Impl >::controlCallback_
private

Definition at line 53 of file BaseWSPeer.h.

◆ port_

template<class Handler, class Impl>
Port const& xrpl::BasePeer< Handler, Impl >::port_
protectedinherited

Definition at line 28 of file BasePeer.h.

◆ handler_

template<class Handler, class Impl>
Handler& xrpl::BasePeer< Handler, Impl >::handler_
protectedinherited

Definition at line 29 of file BasePeer.h.

◆ remoteAddress_

template<class Handler, class Impl>
endpoint_type xrpl::BasePeer< Handler, Impl >::remoteAddress_
protectedinherited

Definition at line 30 of file BasePeer.h.

◆ sink_

template<class Handler, class Impl>
beast::WrappedSink xrpl::BasePeer< Handler, Impl >::sink_
protectedinherited

Definition at line 31 of file BasePeer.h.

◆ j_

template<class Handler, class Impl>
beast::Journal const xrpl::BasePeer< Handler, Impl >::j_
protectedinherited

Definition at line 32 of file BasePeer.h.

◆ work_

template<class Handler, class Impl>
boost::asio::executor_work_guard<boost::asio::executor> xrpl::BasePeer< Handler, Impl >::work_
protectedinherited

Definition at line 34 of file BasePeer.h.

◆ strand_

template<class Handler, class Impl>
boost::asio::strand<boost::asio::executor> xrpl::BasePeer< Handler, Impl >::strand_
protectedinherited

Definition at line 35 of file BasePeer.h.

◆ ios_

IOList* xrpl::IOList::Work::ios_ = nullptr
privateinherited

Definition at line 25 of file io_list.h.

◆ appDefined

std::shared_ptr<void> xrpl::WSSession::appDefined
inherited

Definition at line 88 of file WSSession.h.