HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
NET_WebServer Class Reference

#include <NET_WebServer.h>

Public Types

using ServerCallback = std::function< void()>
 
using SignalCallback = std::function< void(UTsignalHandlerArg)>
 

Public Member Functions

 NET_WebServer (const NET_WebServer &)=delete
 
NET_WebServeroperator= (const NET_WebServer &)=delete
 
NET_WebServerSettingssettings ()
 
bool handle (NET_HTTPWebTaskHandler *handler)
 Handle an http request. More...
 
bool handleWebSocket (NET_WebSocketHandler *handler, const UT_StringHolder &msg)
 Handle an api websocket request. More...
 
void addMiddleware (NET_WebMiddleware::RequestMiddleware mw)
 
void addMiddleware (NET_WebMiddleware::ResponseMiddleware mw)
 
void requestPortShutdown (int port)
 
SYS_FORCE_INLINE void requestFullShutdown ()
 Request that all server apps shutdown. More...
 
void shutdown ()
 Shutdown the webserver immediately. More...
 
void addShutdownCallback (ServerCallback clb)
 
const UT_StringHolderprogram () const
 
void configureThreadFarm (int max_threads)
 
bool hasRequestedQuitting () const
 
void queueEndpoint (NET_WebEndpointPtr ep)
 
void setTaskFactory (UT_UniquePtr< NET_WebTaskFactory > factory)
 
bool run (const NET_PortInformationSPtr &port_info, bool is_single_instance)
 Run the server with the provided port information. More...
 
bool run (const UT_Map< int, NET_PortInformationSPtr > &port_infos, bool is_single_instance)
 
bool reload (const NET_PortInformationSPtr &port_info)
 Reload the server. This adds the new port to the server. This will return once its added the port to the queue. More...
 
bool reload (const UT_Map< int, NET_PortInformationSPtr > &port_infos)
 
bool checkReadIp (const NET_WebEndpoint &ep, bool log_error=true) const
 
bool checkWriteIp (const NET_WebEndpoint &ep, bool log_error=true) const
 
bool checkReadIp (const NET_HTTPRequest &req, bool log_error=true) const
 
bool checkWriteIp (const NET_HTTPRequest &req, bool log_error=true) const
 
bool checkReadIp (const unsigned short cip[4], bool log_error=true) const
 
bool checkWriteIp (const unsigned short cip[4], bool log_error=true) const
 
void setTerminateCallback (SignalCallback clb)
 
void addKeepAliveEndpoint (NET_WebEndpointPtr keep_alive)
 
NET_WebSchedulerscheduler ()
 
NET_WebTaskHandlerPtr createHandler (NET_WebEndpoint &ep, NET_WebTaskFactory::ProtocolId id, const char *path=nullptr) const
 
NET_WebTaskHandlerPtr createHandler (NET_WebEndpoint &ep) const
 
bool supportsProtocol (NET_WebTaskFactory::ProtocolId id, const char *path=nullptr) const
 
bool supportsProtocol (NET_WebEndpoint &ep) const
 
NET_WebStatsManagerstatsManager ()
 
void endpointCreated ()
 
void endpointDestroyed ()
 
int32 currentTaskCount () const
 

Static Public Member Functions

static NET_WebServerinstance ()
 
template<typename... Args>
static bool sendResponse (NET_WebEndpoint &ep, NET_HTTPRequest &req, NET_HTTPStatusCode code, Args &&...args)
 
static bool sendResponse (NET_WebEndpoint &ep, NET_HTTPRequest &req, NET_WebResponse &resp)
 
static NET_WebResponse defaultOptionsRouteCallback (NET_HTTPRequest &req)
 
static void configureRequest (NET_HTTPRequest &req)
 
static bool isLocal (const NET_WebEndpoint &ep)
 
static bool isLocal (const NET_HTTPRequest &req)
 
static bool isLocal (const unsigned short ip[4])
 
static void serverIp (unsigned short ip[4])
 
static UT_StringHolder serverIpStr ()
 
static constexpr UT_StringLit releaseLabel ()
 

Detailed Description

Definition at line 153 of file NET_WebServer.h.

Member Typedef Documentation

using NET_WebServer::ServerCallback = std::function<void()>

Definition at line 156 of file NET_WebServer.h.

Definition at line 157 of file NET_WebServer.h.

Constructor & Destructor Documentation

NET_WebServer::NET_WebServer ( const NET_WebServer )
delete

Member Function Documentation

void NET_WebServer::addKeepAliveEndpoint ( NET_WebEndpointPtr  keep_alive)
void NET_WebServer::addMiddleware ( NET_WebMiddleware::RequestMiddleware  mw)
inline

Definition at line 211 of file NET_WebServer.h.

void NET_WebServer::addMiddleware ( NET_WebMiddleware::ResponseMiddleware  mw)
inline

Definition at line 215 of file NET_WebServer.h.

void NET_WebServer::addShutdownCallback ( ServerCallback  clb)
bool NET_WebServer::checkReadIp ( const NET_WebEndpoint ep,
bool  log_error = true 
) const
bool NET_WebServer::checkReadIp ( const NET_HTTPRequest req,
bool  log_error = true 
) const
bool NET_WebServer::checkReadIp ( const unsigned short  cip[4],
bool  log_error = true 
) const
bool NET_WebServer::checkWriteIp ( const NET_WebEndpoint ep,
bool  log_error = true 
) const
bool NET_WebServer::checkWriteIp ( const NET_HTTPRequest req,
bool  log_error = true 
) const
bool NET_WebServer::checkWriteIp ( const unsigned short  cip[4],
bool  log_error = true 
) const
static void NET_WebServer::configureRequest ( NET_HTTPRequest req)
static
void NET_WebServer::configureThreadFarm ( int  max_threads)
NET_WebTaskHandlerPtr NET_WebServer::createHandler ( NET_WebEndpoint ep,
NET_WebTaskFactory::ProtocolId  id,
const char *  path = nullptr 
) const
NET_WebTaskHandlerPtr NET_WebServer::createHandler ( NET_WebEndpoint ep) const
inline

Definition at line 294 of file NET_WebServer.h.

int32 NET_WebServer::currentTaskCount ( ) const
inline

Definition at line 319 of file NET_WebServer.h.

static NET_WebResponse NET_WebServer::defaultOptionsRouteCallback ( NET_HTTPRequest req)
static
void NET_WebServer::endpointCreated ( )
inline

Definition at line 317 of file NET_WebServer.h.

void NET_WebServer::endpointDestroyed ( )
inline

Definition at line 318 of file NET_WebServer.h.

bool NET_WebServer::handle ( NET_HTTPWebTaskHandler handler)

Handle an http request.

Parameters
handlerThe handler that we want the server to execute on
Returns
True if we want the connection closed for some reason.
bool NET_WebServer::handleWebSocket ( NET_WebSocketHandler handler,
const UT_StringHolder msg 
)

Handle an api websocket request.

Parameters
handlerThe handler that we want the server to execute on
Returns
True if we want the connection closed for some reason.
bool NET_WebServer::hasRequestedQuitting ( ) const
inline

Definition at line 232 of file NET_WebServer.h.

static NET_WebServer& NET_WebServer::instance ( )
static
static bool NET_WebServer::isLocal ( const NET_WebEndpoint ep)
static
static bool NET_WebServer::isLocal ( const NET_HTTPRequest req)
static
static bool NET_WebServer::isLocal ( const unsigned short  ip[4])
static
NET_WebServer& NET_WebServer::operator= ( const NET_WebServer )
delete
const UT_StringHolder& NET_WebServer::program ( ) const
inline

Definition at line 228 of file NET_WebServer.h.

void NET_WebServer::queueEndpoint ( NET_WebEndpointPtr  ep)
static constexpr UT_StringLit NET_WebServer::releaseLabel ( )
inlinestatic

Definition at line 280 of file NET_WebServer.h.

bool NET_WebServer::reload ( const NET_PortInformationSPtr port_info)

Reload the server. This adds the new port to the server. This will return once its added the port to the queue.

Parameters
port_infoThe port_info we would like to add into the already running server.
Returns
True if the reload operation worked. This returns immediately.
bool NET_WebServer::reload ( const UT_Map< int, NET_PortInformationSPtr > &  port_infos)
SYS_FORCE_INLINE void NET_WebServer::requestFullShutdown ( )
inline

Request that all server apps shutdown.

Definition at line 222 of file NET_WebServer.h.

void NET_WebServer::requestPortShutdown ( int  port)
bool NET_WebServer::run ( const NET_PortInformationSPtr port_info,
bool  is_single_instance 
)

Run the server with the provided port information.

Parameters
port_infoThe port we would like to run the server with.
Returns
True if running the server was a success. This returns once the server is completely finished running.
bool NET_WebServer::run ( const UT_Map< int, NET_PortInformationSPtr > &  port_infos,
bool  is_single_instance 
)
NET_WebScheduler& NET_WebServer::scheduler ( )
inline

Definition at line 278 of file NET_WebServer.h.

template<typename... Args>
static bool NET_WebServer::sendResponse ( NET_WebEndpoint ep,
NET_HTTPRequest req,
NET_HTTPStatusCode  code,
Args &&...  args 
)
inlinestatic

Definition at line 170 of file NET_WebServer.h.

static bool NET_WebServer::sendResponse ( NET_WebEndpoint ep,
NET_HTTPRequest req,
NET_WebResponse resp 
)
inlinestatic

Definition at line 181 of file NET_WebServer.h.

static void NET_WebServer::serverIp ( unsigned short  ip[4])
static
static UT_StringHolder NET_WebServer::serverIpStr ( )
static
void NET_WebServer::setTaskFactory ( UT_UniquePtr< NET_WebTaskFactory factory)
void NET_WebServer::setTerminateCallback ( SignalCallback  clb)
inline

Definition at line 274 of file NET_WebServer.h.

NET_WebServerSettings& NET_WebServer::settings ( )
inline

Definition at line 164 of file NET_WebServer.h.

void NET_WebServer::shutdown ( )

Shutdown the webserver immediately.

NET_WebStatsManager& NET_WebServer::statsManager ( )
inline

Definition at line 315 of file NET_WebServer.h.

bool NET_WebServer::supportsProtocol ( NET_WebTaskFactory::ProtocolId  id,
const char *  path = nullptr 
) const
inline

Definition at line 300 of file NET_WebServer.h.

bool NET_WebServer::supportsProtocol ( NET_WebEndpoint ep) const
inline

Definition at line 308 of file NET_WebServer.h.


The documentation for this class was generated from the following file: