22#include "util/Taggable.hpp"
23#include "web/AdminVerificationStrategy.hpp"
24#include "web/PlainWsSession.hpp"
25#include "web/dosguard/DOSGuardInterface.hpp"
26#include "web/impl/HttpBase.hpp"
27#include "web/interface/Concepts.hpp"
28#include "web/interface/ConnectionBase.hpp"
30#include <boost/asio/ip/tcp.hpp>
31#include <boost/beast/core/error.hpp>
32#include <boost/beast/core/flat_buffer.hpp>
33#include <boost/beast/core/tcp_stream.hpp>
43using tcp = boost::asio::ip::tcp;
53template <SomeServerHandler HandlerType>
55 public std::enable_shared_from_this<HttpSession<HandlerType>> {
56 boost::beast::tcp_stream stream_;
57 std::reference_wrapper<util::TagDecoratorFactory const> tagFactory_;
58 std::uint32_t maxWsSendingQueueSize_;
75 std::string
const& ip,
76 std::shared_ptr<AdminVerificationStrategy>
const& adminVerification,
77 std::reference_wrapper<util::TagDecoratorFactory const> tagFactory,
78 std::reference_wrapper<dosguard::DOSGuardInterface> dosGuard,
79 std::shared_ptr<HandlerType>
const& handler,
80 boost::beast::flat_buffer buffer,
81 std::uint32_t maxWsSendingQueueSize
91 , stream_(std::move(socket))
92 , tagFactory_(tagFactory)
93 , maxWsSendingQueueSize_(maxWsSendingQueueSize)
100 boost::beast::tcp_stream&
110 boost::asio::dispatch(
111 stream_.get_executor(),
112 boost::beast::bind_front_handler(
122 boost::beast::error_code ec;
123 stream_.socket().shutdown(tcp::socket::shutdown_send, ec);
130 std::make_shared<WsUpgrader<HandlerType>>(
136 std::move(this->buffer_),
137 std::move(this->req_),
139 maxWsSendingQueueSize_
Represents a HTTP connection established by a client.
Definition HttpSession.hpp:55
void doClose()
Closes the underlying socket.
Definition HttpSession.hpp:120
boost::beast::tcp_stream & stream()
Definition HttpSession.hpp:101
HttpSession(tcp::socket &&socket, std::string const &ip, std::shared_ptr< AdminVerificationStrategy > const &adminVerification, std::reference_wrapper< util::TagDecoratorFactory const > tagFactory, std::reference_wrapper< dosguard::DOSGuardInterface > dosGuard, std::shared_ptr< HandlerType > const &handler, boost::beast::flat_buffer buffer, std::uint32_t maxWsSendingQueueSize)
Create a new session.
Definition HttpSession.hpp:73
void run()
Starts reading from the stream.
Definition HttpSession.hpp:108
void upgrade()
Upgrade to WebSocket connection.
Definition HttpSession.hpp:128
This is the implementation class for http sessions.
Definition HttpBase.hpp:82
This namespace implements the web server and related components.
Definition Types.hpp:43
bool isAdmin() const
Indicates whether the connection has admin privileges.
Definition ConnectionBase.hpp:111