Arduino DLNA Server
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
tiny_dlna::HttpServerUsingTask< ClientType, ServerType > Class Template Reference

HTTP server implementation that runs in a separate task/thread. More...

#include <HttpServerUsingTask.h>

Inheritance diagram for tiny_dlna::HttpServerUsingTask< ClientType, ServerType >:
Inheritance graph
[legend]

Public Member Functions

 HttpServerUsingTask (ServerType &server, int bufferSize=1024, int taskStackSize=1024 *8, int taskPriority=1)
 
 ~HttpServerUsingTask ()
 
bool begin () override
 
void end () override
 
bool doLoop () override
 Process server loop.
 
IPAddress & localIP () override
 Provides the local ip address.
 
void rewrite (const char *from, const char *to) override
 adds a rewrite rule
 
void on (const char *url, TinyMethodID method, web_callback_fn fn, void *ctx[]=nullptr, int ctxCount=0) override
 register a generic handler
 
void on (const char *url, TinyMethodID method, const char *mime, web_callback_fn fn) override
 register a handler with mime
 
void on (const char *url, TinyMethodID method, const char *mime, const char *result) override
 register a handler which provides the indicated string
 
void on (const char *url, TinyMethodID method, const char *mime, const uint8_t *data, int len) override
 register a handler which provides the indicated string
 
void on (const char *url, TinyMethodID method, Url &redirect) override
 register a redirection
 
bool onRequest (const char *path) override
 
void addHandler (HttpRequestHandlerLine *handlerLinePtr)
 adds a new handler
 
bool copy () override
 Call this method from your loop!
 
 operator bool () override
 Provides true if the server has been started.
 
bool isActive () override
 
const char * localHost () override
 Determines the local ip address.
 
void setNoConnectDelay (int delay) override
 
void setReference (void *reference) override
 Definesa reference/context object.
 
void * getReference () override
 Provides access to a reference/context object.
 

Protected Member Functions

void removeClosedClients ()
 
const char * nullstr (const char *in)
 
void processRequest (ClientType *p_client)
 
const char * resolveRewrite (const char *from)
 
bool matchesMime (const char *handler_mime, const char *request_mime)
 

Protected Attributes

Task server_task_
 
List< HttpRequestHandlerLine * > handler_collection
 
List< HttpRequestRewrite * > rewrite_collection
 
ListLockFree< ClientType > open_clients
 
HttpClientHandler< ClientType > client_handler
 
ListLockFree< ClientType >::Iterator current_client_iterator
 
ServerType * server_ptr = nullptr
 
bool is_active
 
const char * local_host = nullptr
 
int no_connect_delay = 5
 
void * ref = nullptr
 

Detailed Description

template<typename ClientType, typename ServerType>
class tiny_dlna::HttpServerUsingTask< ClientType, ServerType >

HTTP server implementation that runs in a separate task/thread.

This class extends HttpServer and manages the server loop in a dedicated task using the Task class. It is templated on the client and server types, allowing flexibility for different network stacks.

Template Parameters
ClientTypeThe type representing the network client (e.g., WiFiClient).
ServerTypeThe type representing the network server (e.g., WiFiServer).
Note
The server loop is executed in a background task, which periodically calls doLoop().

Example usage:

HTTP server implementation that runs in a separate task/thread.
Definition: HttpServerUsingTask.h:29

Constructor & Destructor Documentation

◆ HttpServerUsingTask()

template<typename ClientType , typename ServerType >
tiny_dlna::HttpServerUsingTask< ClientType, ServerType >::HttpServerUsingTask ( ServerType &  server,
int  bufferSize = 1024,
int  taskStackSize = 1024 * 8,
int  taskPriority = 1 
)
inline

◆ ~HttpServerUsingTask()

template<typename ClientType , typename ServerType >
tiny_dlna::HttpServerUsingTask< ClientType, ServerType >::~HttpServerUsingTask ( )
inline

Member Function Documentation

◆ addHandler()

template<typename ClientType , typename ServerType >
void tiny_dlna::HttpServer< ClientType, ServerType >::addHandler ( HttpRequestHandlerLine handlerLinePtr)
inlinevirtualinherited

adds a new handler

Implements tiny_dlna::IHttpServer.

◆ begin()

template<typename ClientType , typename ServerType >
bool tiny_dlna::HttpServerUsingTask< ClientType, ServerType >::begin ( )
inlineoverridevirtual

◆ copy()

template<typename ClientType , typename ServerType >
bool tiny_dlna::HttpServer< ClientType, ServerType >::copy ( )
inlineoverridevirtualinherited

Call this method from your loop!

Implements tiny_dlna::IHttpServer.

◆ doLoop()

template<typename ClientType , typename ServerType >
bool tiny_dlna::HttpServerUsingTask< ClientType, ServerType >::doLoop ( )
inlineoverridevirtual

Process server loop.

Implements tiny_dlna::IHttpServer.

◆ end()

template<typename ClientType , typename ServerType >
void tiny_dlna::HttpServerUsingTask< ClientType, ServerType >::end ( )
inlineoverridevirtual

◆ getReference()

template<typename ClientType , typename ServerType >
void * tiny_dlna::HttpServer< ClientType, ServerType >::getReference ( )
inlineoverridevirtualinherited

Provides access to a reference/context object.

Implements tiny_dlna::IHttpServer.

◆ isActive()

template<typename ClientType , typename ServerType >
bool tiny_dlna::HttpServer< ClientType, ServerType >::isActive ( )
inlineoverridevirtualinherited

◆ localHost()

template<typename ClientType , typename ServerType >
const char * tiny_dlna::HttpServer< ClientType, ServerType >::localHost ( )
inlineoverridevirtualinherited

Determines the local ip address.

Implements tiny_dlna::IHttpServer.

◆ localIP()

template<typename ClientType , typename ServerType >
IPAddress & tiny_dlna::HttpServer< ClientType, ServerType >::localIP ( )
inlineoverridevirtualinherited

Provides the local ip address.

Implements tiny_dlna::IHttpServer.

◆ matchesMime()

template<typename ClientType , typename ServerType >
bool tiny_dlna::HttpServer< ClientType, ServerType >::matchesMime ( const char *  handler_mime,
const char *  request_mime 
)
inlineprotectedinherited

compares mime of handler with mime of request: provides true if they match or one is null (=any value)

◆ nullstr()

template<typename ClientType , typename ServerType >
const char * tiny_dlna::HttpServer< ClientType, ServerType >::nullstr ( const char *  in)
inlineprotectedinherited

◆ on() [1/5]

template<typename ClientType , typename ServerType >
void tiny_dlna::HttpServer< ClientType, ServerType >::on ( const char *  url,
TinyMethodID  method,
const char *  mime,
const char *  result 
)
inlineoverridevirtualinherited

register a handler which provides the indicated string

Implements tiny_dlna::IHttpServer.

◆ on() [2/5]

template<typename ClientType , typename ServerType >
void tiny_dlna::HttpServer< ClientType, ServerType >::on ( const char *  url,
TinyMethodID  method,
const char *  mime,
const uint8_t *  data,
int  len 
)
inlineoverridevirtualinherited

register a handler which provides the indicated string

Implements tiny_dlna::IHttpServer.

◆ on() [3/5]

template<typename ClientType , typename ServerType >
void tiny_dlna::HttpServer< ClientType, ServerType >::on ( const char *  url,
TinyMethodID  method,
const char *  mime,
web_callback_fn  fn 
)
inlineoverridevirtualinherited

register a handler with mime

Implements tiny_dlna::IHttpServer.

◆ on() [4/5]

template<typename ClientType , typename ServerType >
void tiny_dlna::HttpServer< ClientType, ServerType >::on ( const char *  url,
TinyMethodID  method,
Url redirect 
)
inlineoverridevirtualinherited

register a redirection

Implements tiny_dlna::IHttpServer.

◆ on() [5/5]

template<typename ClientType , typename ServerType >
void tiny_dlna::HttpServer< ClientType, ServerType >::on ( const char *  url,
TinyMethodID  method,
web_callback_fn  fn,
void *  ctx[] = nullptr,
int  ctxCount = 0 
)
inlineoverridevirtualinherited

register a generic handler

Implements tiny_dlna::IHttpServer.

◆ onRequest()

template<typename ClientType , typename ServerType >
bool tiny_dlna::HttpServer< ClientType, ServerType >::onRequest ( const char *  path)
inlineoverridevirtualinherited

generic handler - you can overwrite this method to provide your specifc processing logic

Implements tiny_dlna::IHttpServer.

◆ operator bool()

template<typename ClientType , typename ServerType >
tiny_dlna::HttpServer< ClientType, ServerType >::operator bool ( )
inlineoverridevirtualinherited

Provides true if the server has been started.

Implements tiny_dlna::IHttpServer.

◆ processRequest()

template<typename ClientType , typename ServerType >
void tiny_dlna::HttpServer< ClientType, ServerType >::processRequest ( ClientType *  p_client)
inlineprotectedinherited

◆ removeClosedClients()

template<typename ClientType , typename ServerType >
void tiny_dlna::HttpServer< ClientType, ServerType >::removeClosedClients ( )
inlineprotectedinherited

◆ resolveRewrite()

template<typename ClientType , typename ServerType >
const char * tiny_dlna::HttpServer< ClientType, ServerType >::resolveRewrite ( const char *  from)
inlineprotectedinherited

determiens the potentially rewritten url which should be used for the further processing

◆ rewrite()

template<typename ClientType , typename ServerType >
void tiny_dlna::HttpServer< ClientType, ServerType >::rewrite ( const char *  from,
const char *  to 
)
inlineoverridevirtualinherited

adds a rewrite rule

Implements tiny_dlna::IHttpServer.

◆ setNoConnectDelay()

template<typename ClientType , typename ServerType >
void tiny_dlna::HttpServer< ClientType, ServerType >::setNoConnectDelay ( int  delay)
inlineoverridevirtualinherited

◆ setReference()

template<typename ClientType , typename ServerType >
void tiny_dlna::HttpServer< ClientType, ServerType >::setReference ( void *  reference)
inlineoverridevirtualinherited

Definesa reference/context object.

Implements tiny_dlna::IHttpServer.

Member Data Documentation

◆ client_handler

template<typename ClientType , typename ServerType >
HttpClientHandler<ClientType> tiny_dlna::HttpServer< ClientType, ServerType >::client_handler
protectedinherited

◆ current_client_iterator

template<typename ClientType , typename ServerType >
ListLockFree<ClientType>::Iterator tiny_dlna::HttpServer< ClientType, ServerType >::current_client_iterator
protectedinherited
Initial value:
=
ListLockFree< ClientType > open_clients
Definition: HttpServer.h:335
Iterator begin()
Definition: ListLockFree.h:388

◆ handler_collection

template<typename ClientType , typename ServerType >
List<HttpRequestHandlerLine*> tiny_dlna::HttpServer< ClientType, ServerType >::handler_collection
protectedinherited

◆ is_active

template<typename ClientType , typename ServerType >
bool tiny_dlna::HttpServer< ClientType, ServerType >::is_active
protectedinherited

◆ local_host

template<typename ClientType , typename ServerType >
const char* tiny_dlna::HttpServer< ClientType, ServerType >::local_host = nullptr
protectedinherited

◆ no_connect_delay

template<typename ClientType , typename ServerType >
int tiny_dlna::HttpServer< ClientType, ServerType >::no_connect_delay = 5
protectedinherited

◆ open_clients

template<typename ClientType , typename ServerType >
ListLockFree<ClientType> tiny_dlna::HttpServer< ClientType, ServerType >::open_clients
protectedinherited

◆ ref

template<typename ClientType , typename ServerType >
void* tiny_dlna::HttpServer< ClientType, ServerType >::ref = nullptr
protectedinherited

◆ rewrite_collection

template<typename ClientType , typename ServerType >
List<HttpRequestRewrite*> tiny_dlna::HttpServer< ClientType, ServerType >::rewrite_collection
protectedinherited

◆ server_ptr

template<typename ClientType , typename ServerType >
ServerType* tiny_dlna::HttpServer< ClientType, ServerType >::server_ptr = nullptr
protectedinherited

◆ server_task_

template<typename ClientType , typename ServerType >
Task tiny_dlna::HttpServerUsingTask< ClientType, ServerType >::server_task_
protected

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