2017-08-09 14:33:07 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <Poco/Net/TCPServerConnectionFactory.h>
|
2017-09-01 19:04:46 +00:00
|
|
|
#include <common/logger_useful.h>
|
2017-08-09 14:33:07 +00:00
|
|
|
#include "IServer.h"
|
|
|
|
#include "TCPHandler.h"
|
|
|
|
|
2017-09-01 19:04:46 +00:00
|
|
|
namespace Poco { class Logger; }
|
2017-08-09 14:33:07 +00:00
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
|
|
|
class TCPHandlerFactory : public Poco::Net::TCPServerConnectionFactory
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
IServer & server;
|
2017-09-01 19:04:46 +00:00
|
|
|
Poco::Logger * log;
|
2017-08-09 14:33:07 +00:00
|
|
|
|
|
|
|
public:
|
2018-03-13 19:49:21 +00:00
|
|
|
explicit TCPHandlerFactory(IServer & server_, bool secure_ = false)
|
2017-08-09 14:33:07 +00:00
|
|
|
: server(server_)
|
2018-03-13 19:58:26 +00:00
|
|
|
, log(&Logger::get(std::string("TCP") + (secure_ ? "S" : "") + "HandlerFactory"))
|
2017-08-09 14:33:07 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
Poco::Net::TCPServerConnection * createConnection(const Poco::Net::StreamSocket & socket) override
|
|
|
|
{
|
|
|
|
LOG_TRACE(log,
|
|
|
|
"TCP Request. "
|
|
|
|
<< "Address: "
|
|
|
|
<< socket.peerAddress().toString());
|
|
|
|
|
|
|
|
return new TCPHandler(server, socket);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|