rippled
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | List of all members
xrpl::Session Class Referenceabstract

Persistent state information for a connection session. More...

#include <Session.h>

Inheritance diagram for xrpl::Session:
Inheritance graph
[legend]

Public Member Functions

 Session ()=default
 
 Session (Session const &)=delete
 
Sessionoperator= (Session const &)=delete
 
virtual ~Session ()=default
 
virtual beast::Journal journal ()=0
 Returns the Journal to use for logging.
 
virtual Port const & port ()=0
 Returns the Port settings for this connection.
 
virtual beast::IP::Endpoint remoteAddress ()=0
 Returns the remote address of the connection.
 
virtual http_request_typerequest ()=0
 Returns the current HTTP request.
 
virtual std::shared_ptr< Sessiondetach ()=0
 Detach the session.
 
virtual void complete ()=0
 Indicate that the response is complete.
 
virtual void close (bool graceful)=0
 Close the session.
 
virtual std::shared_ptr< WSSessionwebsocketUpgrade ()=0
 Convert the connection to WebSocket.
 
void write (std::string const &s)
 Send a copy of data asynchronously.
 
template<typename BufferSequence >
void write (BufferSequence const &buffers)
 
virtual void write (void const *buffer, std::size_t bytes)=0
 
virtual void write (std::shared_ptr< Writer > const &writer, bool keep_alive)=0
 

Public Attributes

void * tag = nullptr
 A user-definable pointer.
 

Detailed Description

Persistent state information for a connection session.

These values are preserved between calls for efficiency. Some fields are input parameters, some are output parameters, and all only become defined during specific callbacks.

Definition at line 23 of file Session.h.

Constructor & Destructor Documentation

◆ Session() [1/2]

xrpl::Session::Session ( )
default

◆ Session() [2/2]

xrpl::Session::Session ( Session const &  )
delete

◆ ~Session()

virtual xrpl::Session::~Session ( )
virtualdefault

Member Function Documentation

◆ operator=()

Session & xrpl::Session::operator= ( Session const &  )
delete

◆ journal()

virtual beast::Journal xrpl::Session::journal ( )
pure virtual

◆ port()

virtual Port const & xrpl::Session::port ( )
pure virtual

◆ remoteAddress()

virtual beast::IP::Endpoint xrpl::Session::remoteAddress ( )
pure virtual

◆ request()

virtual http_request_type & xrpl::Session::request ( )
pure virtual

◆ write() [1/4]

void xrpl::Session::write ( std::string const &  s)

Send a copy of data asynchronously.

Definition at line 57 of file Session.h.

◆ write() [2/4]

template<typename BufferSequence >
void xrpl::Session::write ( BufferSequence const &  buffers)

Definition at line 65 of file Session.h.

◆ write() [3/4]

virtual void xrpl::Session::write ( void const *  buffer,
std::size_t  bytes 
)
pure virtual

◆ write() [4/4]

virtual void xrpl::Session::write ( std::shared_ptr< Writer > const &  writer,
bool  keep_alive 
)
pure virtual

◆ detach()

virtual std::shared_ptr< Session > xrpl::Session::detach ( )
pure virtual

Detach the session.

This holds the session open so that the response can be sent asynchronously. Calls to io_context::run made by the server will not return until all detached sessions are closed.

Implemented in xrpl::BaseHTTPPeer< Handler, Impl >, xrpl::BaseHTTPPeer< Handler, PlainHTTPPeer< Handler > >, and xrpl::BaseHTTPPeer< Handler, SSLHTTPPeer< Handler > >.

◆ complete()

virtual void xrpl::Session::complete ( )
pure virtual

Indicate that the response is complete.

The handler should call this when it has completed writing the response. If Keep-Alive is indicated on the connection, this will trigger a read for the next request; else, the connection will be closed when all remaining data has been sent.

Implemented in xrpl::BaseHTTPPeer< Handler, Impl >, xrpl::BaseHTTPPeer< Handler, PlainHTTPPeer< Handler > >, and xrpl::BaseHTTPPeer< Handler, SSLHTTPPeer< Handler > >.

◆ close()

virtual void xrpl::Session::close ( bool  graceful)
pure virtual

Close the session.

This will be performed asynchronously. The session will be closed gracefully after all pending writes have completed.

Parameters
gracefultrue to wait until all data has finished sending.

Implemented in xrpl::BaseHTTPPeer< Handler, Impl >, xrpl::BaseHTTPPeer< Handler, PlainHTTPPeer< Handler > >, and xrpl::BaseHTTPPeer< Handler, SSLHTTPPeer< Handler > >.

◆ websocketUpgrade()

virtual std::shared_ptr< WSSession > xrpl::Session::websocketUpgrade ( )
pure virtual

Convert the connection to WebSocket.

Implemented in xrpl::PlainHTTPPeer< Handler >, and xrpl::SSLHTTPPeer< Handler >.

Member Data Documentation

◆ tag

void* xrpl::Session::tag = nullptr

A user-definable pointer.

The initial value is always zero. Changes to the value are persisted between calls.

Definition at line 36 of file Session.h.