rippled
Loading...
Searching...
No Matches
Session.h
1#ifndef XRPL_SERVER_SESSION_H_INCLUDED
2#define XRPL_SERVER_SESSION_H_INCLUDED
3
4#include <xrpl/beast/net/IPEndpoint.h>
5#include <xrpl/beast/utility/Journal.h>
6#include <xrpl/server/WSSession.h>
7#include <xrpl/server/Writer.h>
8
9#include <boost/beast/http/message.hpp>
10
11#include <functional>
12#include <memory>
13#include <ostream>
14#include <vector>
15
16namespace ripple {
17
24{
25public:
26 Session() = default;
27 Session(Session const&) = delete;
28 Session&
29 operator=(Session const&) = delete;
30 virtual ~Session() = default;
31
36 void* tag = nullptr;
37
39 virtual beast::Journal
40 journal() = 0;
41
43 virtual Port const&
44 port() = 0;
45
49
51 virtual http_request_type&
52 request() = 0;
53
56 void
58 {
59 if (!s.empty())
60 write(&s[0], std::distance(s.begin(), s.end()));
61 }
62
63 template <typename BufferSequence>
64 void
65 write(BufferSequence const& buffers)
66 {
67 for (typename BufferSequence::const_iterator iter(buffers.begin());
68 iter != buffers.end();
69 ++iter)
70 {
71 typename BufferSequence::value_type const& buffer(*iter);
72 write(buffer.data(), boost::asio::buffer_size(buffer));
73 }
74 }
75
76 virtual void
77 write(void const* buffer, std::size_t bytes) = 0;
78
79 virtual void
80 write(std::shared_ptr<Writer> const& writer, bool keep_alive) = 0;
81
90 detach() = 0;
91
98 virtual void
99 complete() = 0;
100
106 virtual void
107 close(bool graceful) = 0;
108
112};
113
114} // namespace ripple
115
116#endif
T begin(T... args)
A version-independent IP address and port combination.
Definition IPEndpoint.h:19
A generic endpoint for log messages.
Definition Journal.h:41
Persistent state information for a connection session.
Definition Session.h:24
virtual std::shared_ptr< WSSession > websocketUpgrade()=0
Convert the connection to WebSocket.
virtual beast::IP::Endpoint remoteAddress()=0
Returns the remote address of the connection.
virtual Port const & port()=0
Returns the Port settings for this connection.
virtual std::shared_ptr< Session > detach()=0
Detach the session.
Session(Session const &)=delete
virtual void close(bool graceful)=0
Close the session.
virtual http_request_type & request()=0
Returns the current HTTP request.
virtual ~Session()=default
virtual void write(std::shared_ptr< Writer > const &writer, bool keep_alive)=0
void write(std::string const &s)
Send a copy of data asynchronously.
Definition Session.h:57
void * tag
A user-definable pointer.
Definition Session.h:36
virtual beast::Journal journal()=0
Returns the Journal to use for logging.
void write(BufferSequence const &buffers)
Definition Session.h:65
Session & operator=(Session const &)=delete
virtual void write(void const *buffer, std::size_t bytes)=0
virtual void complete()=0
Indicate that the response is complete.
Session()=default
T distance(T... args)
T empty(T... args)
T end(T... args)
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:6
boost::beast::http::request< boost::beast::http::dynamic_body > http_request_type
Definition Handoff.h:14
Configuration information for a Server listening port.
Definition Port.h:31