rippled
Public Member Functions | Public Attributes | List of all members
ripple::Session Class Referenceabstract

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

Inheritance diagram for ripple::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. More...
 
virtual Port const & port ()=0
 Returns the Port settings for this connection. More...
 
virtual beast::IP::Endpoint remoteAddress ()=0
 Returns the remote address of the connection. More...
 
virtual http_request_typerequest ()=0
 Returns the current HTTP request. More...
 
virtual std::shared_ptr< Sessiondetach ()=0
 Detach the session. More...
 
virtual void complete ()=0
 Indicate that the response is complete. More...
 
virtual void close (bool graceful)=0
 Close the session. More...
 
virtual std::shared_ptr< WSSessionwebsocketUpgrade ()=0
 Convert the connection to WebSocket. More...
 

Public Attributes

void * tag = nullptr
 A user-definable pointer. More...
 
void write (std::string const &s)
 Send a copy of data asynchronously. More...
 
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
 

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 40 of file Session.h.

Constructor & Destructor Documentation

◆ Session() [1/2]

ripple::Session::Session ( )
default

◆ Session() [2/2]

ripple::Session::Session ( Session const &  )
delete

◆ ~Session()

virtual ripple::Session::~Session ( )
virtualdefault

Member Function Documentation

◆ operator=()

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

◆ journal()

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

◆ port()

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

◆ remoteAddress()

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

◆ request()

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

◆ write() [1/4]

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

Send a copy of data asynchronously.

Definition at line 74 of file Session.h.

◆ write() [2/4]

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

Definition at line 82 of file Session.h.

◆ write() [3/4]

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

◆ write() [4/4]

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

◆ detach()

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

Detach the session.

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

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

◆ complete()

virtual void ripple::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 ripple::BaseHTTPPeer< Handler, Impl >, ripple::BaseHTTPPeer< Handler, SSLHTTPPeer< Handler > >, and ripple::BaseHTTPPeer< Handler, PlainHTTPPeer< Handler > >.

◆ close()

virtual void ripple::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 ripple::BaseHTTPPeer< Handler, Impl >, ripple::BaseHTTPPeer< Handler, SSLHTTPPeer< Handler > >, and ripple::BaseHTTPPeer< Handler, PlainHTTPPeer< Handler > >.

◆ websocketUpgrade()

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

Convert the connection to WebSocket.

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

Member Data Documentation

◆ tag

void* ripple::Session::tag = nullptr

A user-definable pointer.

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

Definition at line 53 of file Session.h.