1#pragma once
2
3#include <Poco/Net/TCPServerConnectionFactory.h>
4#include <common/logger_useful.h>
5#include "IServer.h"
6#include "TCPHandler.h"
7
8namespace Poco { class Logger; }
9
10namespace DB
11{
12
13class TCPHandlerFactory : public Poco::Net::TCPServerConnectionFactory
14{
15private:
16 IServer & server;
17 Poco::Logger * log;
18
19public:
20 explicit TCPHandlerFactory(IServer & server_, bool secure_ = false)
21 : server(server_)
22 , log(&Logger::get(std::string("TCP") + (secure_ ? "S" : "") + "HandlerFactory"))
23 {
24 }
25
26 Poco::Net::TCPServerConnection * createConnection(const Poco::Net::StreamSocket & socket) override
27 {
28 LOG_TRACE(log,
29 "TCP Request. "
30 << "Address: "
31 << socket.peerAddress().toString());
32
33 return new TCPHandler(server, socket);
34 }
35};
36
37}
38