dfx 0.1.0
Linux-based dynamic dataflow executor
Loading...
Searching...
No Matches
TcpServerForSession.hpp
1// SPDX-FileCopyrightText: 2025 Vincent Leroy
2// SPDX-License-Identifier: MIT
3//
4// This file is part of dfx.
5//
6// Licensed under the MIT License. See the LICENSE file in the project root
7// for full license information.
8
9#pragma once
10
11// Standard includes
12#include <concepts>
13
14// Project includes
15#include "TcpServer.hpp"
16
17namespace dfx::Server
18{
20template<typename T>
21concept DerivedFromTcpSession = std::derived_from<T, TcpSession>;
22
48template<DerivedFromTcpSession T>
50{
51public:
53
54protected:
63 TcpSessionPtr makeSession(std::string host, std::string serv,
64 TcpServer & server, std::chrono::milliseconds initialTimeout) override
65 { return std::make_shared<T>(std::move(host), std::move(serv), server, initialTimeout); }
66};
67} // !namespace dfx::Server
Convenience TcpServer that instantiates a fixed TcpSession type.
Definition TcpServerForSession.hpp:50
TcpServer(Options options, FdWatch::Poller &poller)
Construct a TCP server bound to a poller.
TcpSessionPtr makeSession(std::string host, std::string serv, TcpServer &server, std::chrono::milliseconds initialTimeout) override
Create a new session of type T for an accepted connection.
Definition TcpServerForSession.hpp:63
TcpServer(Options options, FdWatch::Poller &poller)
Construct a TCP server bound to a poller.
Constrains a type to be derived from dfx::Server::TcpSession.
Definition TcpServerForSession.hpp:21
Definition BaseCommandHandler.hpp:16
std::shared_ptr< TcpSession > TcpSessionPtr
Shared ownership pointer type for sessions.
Definition TcpSession.hpp:227