32#include <sptk5/Logger.h>
33#include <sptk5/net/SSLKeys.h>
34#include <sptk5/net/ServerConnection.h>
35#include <sptk5/threads/SynchronizedQueue.h>
36#include <sptk5/threads/ThreadPool.h>
40class TCPServerListener;
70 using MessageDetails = std::set<MessageDetail>;
96 explicit LogDetails(std::initializer_list<MessageDetail> details)
98 for (
auto detail: details)
100 m_details.insert(detail);
113 return m_details.find(detail) != m_details.end();
118 return m_details.empty();
122 MessageDetails m_details;
123 static const std::map<String, MessageDetail> detailNames;
145 TCPServer(
const String& listenerName, ServerConnection::Type connectionType,
size_t threadLimit = 16,
LogEngine* logEngine =
nullptr,
175 return m_listenerThread !=
nullptr;
187 m_logger->log(priority, message);
242 virtual SServerConnection
createConnection(SOCKET connectionSocket,
const sockaddr_in* peer);
255 mutable SharedMutex m_mutex;
256 std::shared_ptr<TCPServerListener> m_listenerThread;
257 std::shared_ptr<Logger> m_logger;
258 std::shared_ptr<SSLKeys> m_sslKeys;
261 ServerConnection::Type m_connectionType;
262 ServerConnection::Function m_connectionFunction;
Definition: TCPServer.h:53
LogDetails(std::initializer_list< MessageDetail > details)
Definition: TCPServer.h:96
LogDetails(const Strings &details)
MessageDetail
Definition: TCPServer.h:59
bool has(MessageDetail detail) const
Definition: TCPServer.h:111
LogDetails(const MessageDetails &details)
Definition: TCPServer.h:81
Definition: LogEngine.h:60
Definition: ServerConnection.h:56
Definition: TCPServerListener.h:50
Definition: TCPServer.h:133
virtual bool allowConnection(sockaddr_in *connectionRequest)
void host(const Host &host)
TCPServer(const String &listenerName, ServerConnection::Type connectionType, size_t threadLimit=16, LogEngine *logEngine=nullptr, const LogDetails &logDetails=LogDetails())
virtual void onConnection(const ServerConnection::Function &function)
const Host & host() const
void threadEvent(Thread *thread, ThreadEvent::Type eventType, SRunable runable) override
void log(LogPriority priority, const String &message) const
Definition: TCPServer.h:183
bool active() const
Definition: TCPServer.h:173
const SSLKeys & getSSLKeys() const
void listen(uint16_t port)
virtual SServerConnection createConnection(SOCKET connectionSocket, const sockaddr_in *peer)
void setSSLKeys(std::shared_ptr< SSLKeys > sslKeys)
Type
Thread event type.
Definition: ThreadEvent.h:49
Definition: ThreadPool.h:55
LogPriority
Log message priority.
Definition: LogPriority.h:68