xrpld
Toggle main menu visibility
Loading...
Searching...
No Matches
include
xrpl
server
Session.h
1
#pragma once
2
3
#include <xrpl/beast/net/IPEndpoint.h>
4
#include <xrpl/beast/utility/Journal.h>
5
#include <xrpl/server/Handoff.h>
6
#include <xrpl/server/Port.h>
7
#include <xrpl/server/WSSession.h>
8
#include <xrpl/server/Writer.h>
9
10
#include <boost/beast/http/message.hpp>
11
12
#include <
cstddef
>
13
#include <
memory
>
14
#include <
string_view
>
15
16
namespace
xrpl
{
17
24
class
Session
25
{
26
public
:
27
Session
() =
default
;
28
Session
(
Session
const
&) =
delete
;
29
Session
&
30
operator=
(
Session
const
&) =
delete
;
31
virtual
~Session
() =
default
;
32
38
void
*
tag
=
nullptr
;
39
43
virtual
beast::Journal
44
journal
() = 0;
45
49
virtual
Port
const
&
50
port
() = 0;
51
55
virtual
beast::ip::Endpoint
56
remoteAddress
() = 0;
57
61
virtual
HttpRequestType
&
62
request
() = 0;
63
68
void
69
write
(
std::string_view
s)
70
{
71
if
(!s.
empty
())
72
write
(s.
data
(), s.
size
());
73
}
74
75
template
<
typename
BufferSequence>
76
void
77
write
(BufferSequence
const
& buffers)
78
{
79
for
(
typename
BufferSequence::const_iterator iter(buffers.begin()); iter != buffers.end();
80
++iter)
81
{
82
typename
BufferSequence::value_type
const
& buffer(*iter);
83
write
(buffer.data(), boost::asio::buffer_size(buffer));
84
}
85
}
86
87
virtual
void
88
write
(
void
const
* buffer,
std::size_t
bytes) = 0;
89
90
virtual
void
91
write
(
std::shared_ptr<Writer>
const
& writer,
bool
keepAlive) = 0;
92
94
101
virtual
std::shared_ptr<Session>
102
detach
() = 0;
103
111
virtual
void
112
complete
() = 0;
113
120
virtual
void
121
close
(
bool
graceful) = 0;
122
126
virtual
std::shared_ptr<WSSession>
127
websocketUpgrade
() = 0;
128
};
129
130
}
// namespace xrpl
std::string_view
beast::Journal
A generic endpoint for log messages.
Definition
Journal.h:44
beast::ip::Endpoint
A version-independent IP address and port combination.
Definition
IPEndpoint.h:24
xrpl::Session::write
virtual void write(std::shared_ptr< Writer > const &writer, bool keepAlive)=0
xrpl::Session::journal
virtual beast::Journal journal()=0
Returns the Journal to use for logging.
xrpl::Session::Session
Session(Session const &)=delete
xrpl::Session::port
virtual Port const & port()=0
Returns the Port settings for this connection.
xrpl::Session::remoteAddress
virtual beast::ip::Endpoint remoteAddress()=0
Returns the remote address of the connection.
xrpl::Session::write
virtual void write(void const *buffer, std::size_t bytes)=0
xrpl::Session::close
virtual void close(bool graceful)=0
Close the session.
xrpl::Session::detach
virtual std::shared_ptr< Session > detach()=0
Detach the session.
xrpl::Session::write
void write(BufferSequence const &buffers)
Definition
Session.h:77
xrpl::Session::write
void write(std::string_view s)
Send a copy of data asynchronously.
Definition
Session.h:69
xrpl::Session::Session
Session()=default
xrpl::Session::complete
virtual void complete()=0
Indicate that the response is complete.
xrpl::Session::request
virtual HttpRequestType & request()=0
Returns the current HTTP request.
xrpl::Session::~Session
virtual ~Session()=default
xrpl::Session::operator=
Session & operator=(Session const &)=delete
xrpl::Session::websocketUpgrade
virtual std::shared_ptr< WSSession > websocketUpgrade()=0
Convert the connection to WebSocket.
xrpl::Session::tag
void * tag
A user-definable pointer.
Definition
Session.h:38
cstddef
std::string_view::data
T data(T... args)
std::string_view::empty
T empty(T... args)
memory
xrpl
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition
algorithm.h:5
xrpl::HttpRequestType
boost::beast::http::request< boost::beast::http::dynamic_body > HttpRequestType
Definition
Handoff.h:12
std::shared_ptr
std::string_view::size
T size(T... args)
std::size_t
string_view
xrpl::Port
Configuration information for a Server listening port.
Definition
Port.h:29
Generated by
1.17.0