rippled
Loading...
Searching...
No Matches
PlainWSPeer.h
1#pragma once
2
3#include <xrpl/server/detail/BaseWSPeer.h>
4
5#include <boost/beast/core/tcp_stream.hpp>
6
7#include <memory>
8
9namespace xrpl {
10
11template <class Handler>
12class PlainWSPeer : public BaseWSPeer<Handler, PlainWSPeer<Handler>>,
13 public std::enable_shared_from_this<PlainWSPeer<Handler>>
14{
15 friend class BasePeer<Handler, PlainWSPeer>;
16 friend class BaseWSPeer<Handler, PlainWSPeer>;
17
19 using error_code = boost::system::error_code;
20 using endpoint_type = boost::asio::ip::tcp::endpoint;
21 using waitable_timer = boost::asio::basic_waitable_timer<clock_type>;
22 using socket_type = boost::beast::tcp_stream;
23
24 boost::beast::websocket::stream<socket_type> ws_;
25
26public:
27 template <class Body, class Headers>
29 Port const& port,
30 Handler& handler,
31 endpoint_type remote_address,
32 boost::beast::http::request<Body, Headers>&& request,
33 socket_type&& socket,
34 beast::Journal journal);
35};
36
37//------------------------------------------------------------------------------
38
39template <class Handler>
40template <class Body, class Headers>
42 Port const& port,
43 Handler& handler,
44 endpoint_type remote_address,
45 boost::beast::http::request<Body, Headers>&& request,
46 socket_type&& socket,
47 beast::Journal journal)
48 : BaseWSPeer<Handler, PlainWSPeer>(
49 port,
50 handler,
51 socket.get_executor(),
52 waitable_timer{socket.get_executor()},
53 remote_address,
54 std::move(request),
55 journal)
56 , ws_(std::move(socket))
57{
58}
59
60} // namespace xrpl
A generic endpoint for log messages.
Definition Journal.h:40
Represents an active WebSocket connection.
Definition BaseWSPeer.h:26
http_request_type const & request() const override
Definition BaseWSPeer.h:78
boost::beast::websocket::stream< socket_type > ws_
Definition PlainWSPeer.h:24
boost::beast::tcp_stream socket_type
Definition PlainWSPeer.h:22
boost::asio::ip::tcp::endpoint endpoint_type
Definition PlainWSPeer.h:20
boost::system::error_code error_code
Definition PlainWSPeer.h:19
boost::asio::basic_waitable_timer< clock_type > waitable_timer
Definition PlainWSPeer.h:21
PlainWSPeer(Port const &port, Handler &handler, endpoint_type remote_address, boost::beast::http::request< Body, Headers > &&request, socket_type &&socket, beast::Journal journal)
Definition PlainWSPeer.h:41
STL namespace.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:5
Configuration information for a Server listening port.
Definition Port.h:30