22#include "util/Taggable.hpp" 
   23#include "web/ng/Error.hpp" 
   24#include "web/ng/Request.hpp" 
   25#include "web/ng/Response.hpp" 
   27#include <boost/asio/spawn.hpp> 
   28#include <boost/beast/core/flat_buffer.hpp> 
   47    std::optional<bool> isAdmin_;
 
   82        ip_ = std::move(newIp);
 
 
  100    template <std::invocable T>
 
  104        if (not isAdmin_.has_value())
 
 
 
  114    boost::beast::flat_buffer buffer_;
 
  121    static constexpr std::chrono::steady_clock::duration 
kDEFAULT_TIMEOUT = std::chrono::seconds{11};
 
  139    setTimeout(std::chrono::steady_clock::duration newTimeout) = 0;
 
  148    virtual std::expected<void, Error>
 
  157    virtual std::expected<Request, Error>
 
  158    receive(boost::asio::yield_context yield) = 0;
 
  166    close(boost::asio::yield_context yield) = 0;
 
 
  172using ConnectionPtr = std::unique_ptr<Connection>;
 
A factory for TagDecorator instantiation.
Definition Taggable.hpp:182
A base class that allows attaching a tag decorator to a subclass.
Definition Taggable.hpp:253
virtual std::expected< Request, Error > receive(boost::asio::yield_context yield)=0
Receive a request from the client.
virtual std::expected< void, Error > send(Response response, boost::asio::yield_context yield)=0
Send a response to the client.
Connection(std::string ip, boost::beast::flat_buffer buffer, util::TagDecoratorFactory const &tagDecoratorFactory)
Construct a new Connection object.
Definition Connection.cpp:48
virtual void close(boost::asio::yield_context yield)=0
Gracefully close the connection.
virtual void setTimeout(std::chrono::steady_clock::duration newTimeout)=0
Get the timeout for send, receive, and close operations. For WebSocket connections,...
static constexpr std::chrono::steady_clock::duration kDEFAULT_TIMEOUT
The default timeout for send, receive, and close operations.
Definition Connection.hpp:121
Represents an HTTP or Websocket response.
Definition Response.hpp:40