19#include "../transport/listener.h"
59static inline void dispatch_event(
const TcpEvt &evt)
102#if DETWS_WORKER_COUNT > 1
104 QueueHandle_t q = listener_worker_queue(worker_id);
108 while (xQueueReceive(q, &evt, 0) == pdTRUE)
119 while (xQueueReceive(lst->
queue, &evt, 0) == pdTRUE)
#define MAX_LISTENERS
Maximum number of simultaneously active listener ports.
ConnProto
Application protocol spoken on a listener port or connection slot.
@ PROTO_HTTP
HTTP/1.1 with optional WS and SSE upgrades.
#define DETWS_PROTO_MAX
Size of the protocol-handler dispatch table; must exceed the largest ConnProto id.
static void check_timeouts(int worker_id=0)
Scan the pool and force-close connections idle for > conn_timeout_ms.
Listener listener_pool[MAX_LISTENERS]
Static pool of listener contexts. Defined in listener.cpp.
void proto_register_builtins(void)
Register every built-in protocol's handler (the policy list).
Layer 5 (Session) - per-protocol connection handler dispatch table.
void scratch_reset(void)
Reclaim the whole arena (empties it).
Shared per-dispatch scratch arena (Layer 5, session-scoped memory).
void proto_register(ConnProto proto, const ProtoHandler *h)
Register h for protocol proto (replaces any previous handler).
const ProtoHandler * proto_get(ConnProto proto)
Look up the handler for proto.
void server_tick(int worker_id)
Drive the session layer for one Arduino loop iteration.
Layer 5 (Session) - event queue dispatcher and session lifecycle.
State for one TCP listening port.
QueueHandle_t queue
Handle returned by xQueueCreateStatic().
bool active
True after listener_add(), false after listener_stop().
Per-protocol connection event/poll callbacks (Layer 5 dispatch vtable).
void(* on_close)(uint8_t slot)
EvtType::EVT_DISCONNECT / EvtType::EVT_ERROR: tear down slot state.
void(* on_data)(uint8_t slot)
EvtType::EVT_DATA: bytes are available in the slot's rx ring.
void(* on_accept)(uint8_t slot)
EvtType::EVT_CONNECT: a new connection was accepted.
const ProtoHandler * proto_handlers[DETWS_PROTO_MAX]
ConnProto proto
Application protocol for this connection.
Event record posted from lwIP callbacks to the session layer.
EvtType type
What happened.
uint8_t slot_id
Which connection slot is affected.
TcpConn conn_pool[CONN_POOL_SLOTS]
Static pool of connection contexts. Defined in tcp.cpp. Sized CONN_POOL_SLOTS: MAX_CONNS TCP slots pl...
@ EVT_DATA
Data received; bytes are already in the ring buffer.
@ EVT_CONNECT
New connection accepted.
@ EVT_DISCONNECT
Remote peer closed the connection gracefully.
@ EVT_ERROR
lwIP reported an error (PCB may already be freed).