rippled
Loading...
Searching...
No Matches
PlainWSPeer.h
1//------------------------------------------------------------------------------
2/*
3 This file is part of rippled: https://github.com/ripple/rippled
4 Copyright (c) 2012, 2013 Ripple Labs Inc.
5
6 Permission to use, copy, modify, and/or distribute this software for any
7 purpose with or without fee is hereby granted, provided that the above
8 copyright notice and this permission notice appear in all copies.
9
10 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17*/
18//==============================================================================
19
20#ifndef RIPPLE_SERVER_PLAINWSPEER_H_INCLUDED
21#define RIPPLE_SERVER_PLAINWSPEER_H_INCLUDED
22
23#include <xrpl/server/detail/BaseWSPeer.h>
24
25#include <boost/beast/core/tcp_stream.hpp>
26
27#include <memory>
28
29namespace ripple {
30
31template <class Handler>
32class PlainWSPeer : public BaseWSPeer<Handler, PlainWSPeer<Handler>>,
33 public std::enable_shared_from_this<PlainWSPeer<Handler>>
34{
35 friend class BasePeer<Handler, PlainWSPeer>;
36 friend class BaseWSPeer<Handler, PlainWSPeer>;
37
39 using error_code = boost::system::error_code;
40 using endpoint_type = boost::asio::ip::tcp::endpoint;
41 using waitable_timer = boost::asio::basic_waitable_timer<clock_type>;
42 using socket_type = boost::beast::tcp_stream;
43
44 boost::beast::websocket::stream<socket_type> ws_;
45
46public:
47 template <class Body, class Headers>
49 Port const& port,
50 Handler& handler,
51 endpoint_type remote_address,
52 boost::beast::http::request<Body, Headers>&& request,
53 socket_type&& socket,
54 beast::Journal journal);
55};
56
57//------------------------------------------------------------------------------
58
59template <class Handler>
60template <class Body, class Headers>
62 Port const& port,
63 Handler& handler,
64 endpoint_type remote_address,
65 boost::beast::http::request<Body, Headers>&& request,
66 socket_type&& socket,
67 beast::Journal journal)
68 : BaseWSPeer<Handler, PlainWSPeer>(
69 port,
70 handler,
71 socket.get_executor(),
72 waitable_timer{socket.get_executor()},
73 remote_address,
74 std::move(request),
75 journal)
76 , ws_(std::move(socket))
77{
78}
79
80} // namespace ripple
81
82#endif
A generic endpoint for log messages.
Definition Journal.h:60
Represents an active WebSocket connection.
Definition BaseWSPeer.h:46
http_request_type const & request() const override
Definition BaseWSPeer.h:100
boost::asio::basic_waitable_timer< clock_type > waitable_timer
Definition PlainWSPeer.h:41
boost::beast::websocket::stream< socket_type > ws_
Definition PlainWSPeer.h:44
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:61
boost::asio::ip::tcp::endpoint endpoint_type
Definition PlainWSPeer.h:40
boost::system::error_code error_code
Definition PlainWSPeer.h:39
boost::beast::tcp_stream socket_type
Definition PlainWSPeer.h:42
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:25
STL namespace.
Configuration information for a Server listening port.
Definition Port.h:50