#include <WSListener.h>
Public Member Functions | |
WSListener (const WSServices &services, LogEngine &logger, const String &hostname, size_t threadCount, const WSConnection::Options &options) | |
Public Member Functions inherited from sptk::TCPServer | |
TCPServer (const String &listenerName, ServerConnection::Type connectionType, size_t threadLimit=16, LogEngine *logEngine=nullptr, const LogDetails &logDetails=LogDetails()) | |
~TCPServer () override | |
const Host & | host () const |
void | listen (uint16_t port) |
void | stop () override |
bool | active () const |
void | log (LogPriority priority, const String &message) const |
const LogDetails & | logDetails () const |
void | setSSLKeys (std::shared_ptr< SSLKeys > sslKeys) |
const SSLKeys & | getSSLKeys () const |
virtual void | onConnection (const ServerConnection::Function &function) |
Public Member Functions inherited from sptk::ThreadPool | |
ThreadPool (uint32_t threadLimit, std::chrono::milliseconds threadIdleSeconds, const String &threadName, LogEngine *logEngine) | |
virtual void | execute (const SRunable &task) |
void | threadEvent (Thread *thread, ThreadEvent::Type eventType, SRunable runable) override |
virtual void | stop () |
size_t | size () const |
Public Member Functions inherited from sptk::ThreadEvent | |
virtual void | threadEvent (Thread *thread, Type eventType, SRunable runable)=0 |
Thread event callback function. More... | |
virtual | ~ThreadEvent ()=default |
Destructor. | |
Protected Member Functions | |
SServerConnection | createConnection (SOCKET connectionSocket, const sockaddr_in *peer) override |
Protected Member Functions inherited from sptk::TCPServer | |
void | host (const Host &host) |
virtual bool | allowConnection (sockaddr_in *connectionRequest) |
virtual SServerConnection | createConnection (SOCKET connectionSocket, const sockaddr_in *peer) |
void | threadEvent (Thread *thread, ThreadEvent::Type eventType, SRunable runable) override |
Additional Inherited Members | |
Public Types inherited from sptk::ThreadEvent | |
enum class | Type : uint8_t { THREAD_STARTED , THREAD_FINISHED , RUNABLE_STARTED , RUNABLE_FINISHED , IDLE_TIMEOUT } |
Thread event type. More... | |
Web Service Listener
Simple server to accept Web Service requests. Actual request processing is implemented in Web Service request processor, passed to constructor. As a bonus, WSListener also serves static files, located in staticFilesDirectory. That may be used to implement a web application.
sptk::WSListener::WSListener | ( | const WSServices & | services, |
LogEngine & | logger, | ||
const String & | hostname, | ||
size_t | threadCount, | ||
const WSConnection::Options & | options | ||
) |
Constructor
service | Web Service request processor |
logger | Logger |
hostname | This service hostname |
threadCount | Max number of simultaneously running requests |
options | Client connection options |
|
overrideprotectedvirtual |
Creates connection thread derived from CTCPServerConnection
Application should override this method to create concrete connection object. Created connection object is maintained by CTCPServer.
connectionSocket | Already accepted incoming connection socket |
peer | Incoming connection information |
Reimplemented from sptk::TCPServer.