rippled
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | Protected Types | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes | Friends | List of all members
ripple::BaseWSPeer< Handler, Impl > Class Template Reference

Represents an active WebSocket connection. More...

#include <BaseWSPeer.h>

Inheritance diagram for ripple::BaseWSPeer< Handler, Impl >:
Inheritance graph
[legend]
Collaboration diagram for ripple::BaseWSPeer< Handler, Impl >:
Collaboration graph
[legend]

Public Member Functions

template<class Body , class Headers >
 BaseWSPeer (Port const &port, Handler &handler, boost::asio::executor const &executor, waitable_timer timer, endpoint_type remote_address, 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 & remote_endpoint () 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.
 
io_listios ()
 Return the io_list 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 on_ws_handshake (error_code const &ec)
 
void do_write ()
 
void on_write (error_code const &ec)
 
void on_write_fin (error_code const &ec)
 
void do_read ()
 
void on_read (error_code const &ec)
 
void on_close (error_code const &ec)
 
void start_timer ()
 
void cancel_timer ()
 
void on_ping (error_code const &ec)
 
void on_ping_pong (boost::beast::websocket::frame_type kind, boost::beast::string_view payload)
 
void on_timer (error_code ec)
 
template<class String >
void fail (error_code ec, String const &what)
 

Protected Attributes

Port const & port_
 
Handler & handler_
 
endpoint_type remote_address_
 
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 do_close_ = false
 The socket has been closed, or will close after the next write finishes.
 
boost::beast::websocket::close_reason cr_
 
waitable_timer timer_
 
bool close_on_timer_ = false
 
bool ping_active_ = false
 
boost::beast::websocket::ping_data payload_
 
error_code ec_
 
std::function< void(boost::beast::websocket::frame_type, boost::beast::string_view)> control_callback_
 
io_listios_ = nullptr
 

Friends

class BasePeer< Handler, Impl >
 

Detailed Description

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

Represents an active WebSocket connection.

Definition at line 45 of file BaseWSPeer.h.

Member Typedef Documentation

◆ clock_type

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

Definition at line 48 of file BaseWSPeer.h.

◆ error_code

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

Definition at line 49 of file BaseWSPeer.h.

◆ endpoint_type

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

Definition at line 50 of file BaseWSPeer.h.

◆ waitable_timer

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

Definition at line 51 of file BaseWSPeer.h.

Constructor & Destructor Documentation

◆ BaseWSPeer()

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

Definition at line 177 of file BaseWSPeer.h.

Member Function Documentation

◆ run()

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

Implements ripple::WSSession.

Definition at line 194 of file BaseWSPeer.h.

◆ port()

template<class Handler , class Impl >
Port const & ripple::BaseWSPeer< Handler, Impl >::port ( ) const
overridevirtual

Implements ripple::WSSession.

Definition at line 94 of file BaseWSPeer.h.

◆ request()

template<class Handler , class Impl >
http_request_type const & ripple::BaseWSPeer< Handler, Impl >::request ( ) const
overridevirtual

Implements ripple::WSSession.

Definition at line 100 of file BaseWSPeer.h.

◆ remote_endpoint()

template<class Handler , class Impl >
boost::asio::ip::tcp::endpoint const & ripple::BaseWSPeer< Handler, Impl >::remote_endpoint ( ) const
overridevirtual

Implements ripple::WSSession.

Definition at line 106 of file BaseWSPeer.h.

◆ send()

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

Send a WebSockets message.

Implements ripple::WSSession.

Definition at line 228 of file BaseWSPeer.h.

◆ close() [1/2]

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

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

Definition at line 254 of file BaseWSPeer.h.

◆ close() [2/2]

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

Implements ripple::WSSession.

Definition at line 261 of file BaseWSPeer.h.

◆ complete()

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

Indicate that the response is complete.

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

Implements ripple::WSSession.

Definition at line 290 of file BaseWSPeer.h.

◆ impl()

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

Definition at line 125 of file BaseWSPeer.h.

◆ on_ws_handshake()

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

Definition at line 301 of file BaseWSPeer.h.

◆ do_write()

template<class Handler , class Impl >
void ripple::BaseWSPeer< Handler, Impl >::do_write ( )
protected

Definition at line 311 of file BaseWSPeer.h.

◆ on_write()

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

Definition at line 322 of file BaseWSPeer.h.

◆ on_write_fin()

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

Definition at line 356 of file BaseWSPeer.h.

◆ do_read()

template<class Handler , class Impl >
void ripple::BaseWSPeer< Handler, Impl >::do_read ( )
protected

Definition at line 378 of file BaseWSPeer.h.

◆ on_read()

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

Definition at line 396 of file BaseWSPeer.h.

◆ on_close()

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

Definition at line 412 of file BaseWSPeer.h.

◆ start_timer()

template<class Handler , class Impl >
void ripple::BaseWSPeer< Handler, Impl >::start_timer ( )
protected

Definition at line 419 of file BaseWSPeer.h.

◆ cancel_timer()

template<class Handler , class Impl >
void ripple::BaseWSPeer< Handler, Impl >::cancel_timer ( )
protected

Definition at line 446 of file BaseWSPeer.h.

◆ on_ping()

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

Definition at line 460 of file BaseWSPeer.h.

◆ on_ping_pong()

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

Definition at line 472 of file BaseWSPeer.h.

◆ on_timer()

template<class Handler , class Impl >
void ripple::BaseWSPeer< Handler, Impl >::on_timer ( error_code  ec)
protected

Definition at line 493 of file BaseWSPeer.h.

◆ fail()

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

Definition at line 526 of file BaseWSPeer.h.

◆ destroy()

template<class = void>
void ripple::io_list::work::destroy ( )
privateinherited

Definition at line 182 of file io_list.h.

◆ ios()

io_list & ripple::io_list::work::ios ( )
inherited

Return the io_list associated with the work.

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

Definition at line 60 of file io_list.h.

Friends And Related Symbol Documentation

◆ BasePeer< Handler, Impl >

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

Definition at line 526 of file BaseWSPeer.h.

Member Data Documentation

◆ request_

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

Definition at line 57 of file BaseWSPeer.h.

◆ rb_

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

Definition at line 58 of file BaseWSPeer.h.

◆ wb_

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

Definition at line 59 of file BaseWSPeer.h.

◆ wq_

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

Definition at line 60 of file BaseWSPeer.h.

◆ do_close_

template<class Handler , class Impl >
bool ripple::BaseWSPeer< Handler, Impl >::do_close_ = 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 64 of file BaseWSPeer.h.

◆ cr_

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

Definition at line 65 of file BaseWSPeer.h.

◆ timer_

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

Definition at line 66 of file BaseWSPeer.h.

◆ close_on_timer_

template<class Handler , class Impl >
bool ripple::BaseWSPeer< Handler, Impl >::close_on_timer_ = false
private

Definition at line 67 of file BaseWSPeer.h.

◆ ping_active_

template<class Handler , class Impl >
bool ripple::BaseWSPeer< Handler, Impl >::ping_active_ = false
private

Definition at line 68 of file BaseWSPeer.h.

◆ payload_

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

Definition at line 69 of file BaseWSPeer.h.

◆ ec_

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

Definition at line 70 of file BaseWSPeer.h.

◆ control_callback_

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

Definition at line 73 of file BaseWSPeer.h.

◆ port_

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

Definition at line 47 of file BasePeer.h.

◆ handler_

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

Definition at line 48 of file BasePeer.h.

◆ remote_address_

template<class Handler , class Impl >
endpoint_type ripple::BasePeer< Handler, Impl >::remote_address_
protectedinherited

Definition at line 49 of file BasePeer.h.

◆ sink_

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

Definition at line 50 of file BasePeer.h.

◆ j_

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

Definition at line 51 of file BasePeer.h.

◆ work_

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

Definition at line 53 of file BasePeer.h.

◆ strand_

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

Definition at line 54 of file BasePeer.h.

◆ ios_

io_list* ripple::io_list::work::ios_ = nullptr
privateinherited

Definition at line 45 of file io_list.h.

◆ appDefined

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

Definition at line 109 of file WSSession.h.