DeterministicESPAsyncWebServer 1.2.0
Zero-allocation, bounded-execution async HTTP server for ESP32
Loading...
Searching...
No Matches
session.h File Reference

Layer 5 (Session) — event queue dispatcher and session lifecycle. More...

#include "freertos/FreeRTOS.h"
#include "freertos/queue.h"
#include "transport.h"
#include <Arduino.h>

Go to the source code of this file.

Functions

void server_tick ()
 Drive the session layer for one Arduino loop iteration.
 
void http_reset (uint8_t slot_id)
 Reset a presentation-layer parser slot (Layer 6 forward decl).
 
void http_parse (uint8_t slot_id)
 Advance the HTTP parser for a slot (Layer 6 forward decl).
 

Detailed Description

Layer 5 (Session) — event queue dispatcher and session lifecycle.

The session layer is the bridge between the interrupt-driven transport layer and the application-layer HTTP handler. It processes all pending events from the FreeRTOS queue in a single bounded loop, ensuring that server_tick() has a deterministic worst-case execution time of O(queue_depth + MAX_CONNS).

Author
Douglas Quigg (dstroy0)
Date
2026

Definition in file session.h.

Function Documentation

◆ server_tick()

void server_tick ( )

Drive the session layer for one Arduino loop iteration.

Call this function from your loop() (or indirectly via DetWebServer::handle()). It performs three actions in order:

  1. Timeout sweep — calls DeterministicAsyncTCP::check_timeouts() to force-close connections that have been idle for > CONN_TIMEOUT_MS.
  2. Event drain — dequeues all pending TcpEvt records from the FreeRTOS queue. Each event is dispatched:
  3. Returns — upper layers may then inspect http_pool[] for PARSE_COMPLETE slots and send responses.
Note
The event-drain loop is bounded by the queue depth (16 entries). Even in the absolute worst case this function executes in O(1).

Definition at line 15 of file session.cpp.

References DeterministicAsyncTCP::check_timeouts(), EVT_CONNECT, EVT_DATA, EVT_DISCONNECT, EVT_ERROR, http_parse(), http_reset(), DeterministicAsyncTCP::queue, TcpEvt::slot_id, and TcpEvt::type.

Referenced by DetWebServer::handle().

◆ http_reset()

void http_reset ( uint8_t  slot_id)

Reset a presentation-layer parser slot (Layer 6 forward decl).

Parameters
slot_idConnection slot to reset.
See also
http_reset in presentation.h

Reset a presentation-layer parser slot (Layer 6 forward decl).

Delegates to http_parser_reset(&http_pool[slot_id]). Silently ignores out-of-range slot IDs.

Parameters
slot_idIndex into conn_pool / http_pool (0 … MAX_CONNS-1).

Definition at line 21 of file presentation.cpp.

References http_parser_reset(), http_pool, MAX_CONNS, and HttpReq::slot_id.

Referenced by DetWebServer::begin(), DetWebServer::handle(), DetWebServer::send(), DetWebServer::send_empty(), server_tick(), and DetWebServer::stop().

◆ http_parse()

void http_parse ( uint8_t  slot_id)

Advance the HTTP parser for a slot (Layer 6 forward decl).

Parameters
slot_idConnection slot to parse.
See also
http_parse in presentation.h

Advance the HTTP parser for a slot (Layer 6 forward decl).

Reads all available bytes from conn_pool[slot_id].rx_buffer and feeds each byte to http_parser_feed(). Stops early if the parser reaches a terminal state (PARSE_COMPLETE, PARSE_ERROR, PARSE_ENTITY_TOO_LARGE, PARSE_URI_TOO_LONG).

Silently ignores out-of-range slot IDs.

Parameters
slot_idConnection slot to parse.

Definition at line 29 of file presentation.cpp.

References conn_pool, http_parser_feed(), http_pool, MAX_CONNS, PARSE_COMPLETE, PARSE_ENTITY_TOO_LARGE, PARSE_ERROR, HttpReq::parse_state, PARSE_URI_TOO_LONG, RX_BUF_SIZE, TcpConn::rx_buffer, TcpConn::rx_head, and TcpConn::rx_tail.

Referenced by server_tick().