// clients in epoll loop enum{max_clients=32}; typedef struct ping_state ping_state; struct ping_state { enum{wait_to_ping, wait_for_pong} state; int64_t target_time; // ping or pong send/timeout }; typedef struct ws_client { int fd; // 0 => unused slot (stdin never used) bool is_websocket; // http or websocket connection (ephemeral or permanent) str user_id; // verfified credential - allocated in persistent arena str username; // verfified credential - allocated in persistent arena str room_id; // current room - backed by local buffer (must never exceed ulid_byte_len) int64_t last_activity_ms; // last activity (for timeouts) int64_t expiry_monotonic_ms; // CLOCK_MONOTONIC BWT expiry time relative to boot time ping_state ping_state; // WebSocket fragmentation state int expecting_continuation; int current_opcode; str partial_payload; // memory arenas arena *A; // pointer to per request, scratch arena arena perm; // full client lifetime (for session credentials) uint8_t perm_buf[256]; uint8_t room_id_buf[ulid_byte_len]; // backing store for room_id field } ws_client_t;