ascii-chat 0.11.33
Video chat in your terminal
Loading...
Searching...
No Matches
src/discovery-service/server.h
Go to the documentation of this file.
1#pragma once
2
26#include <stdint.h>
27#include <stdbool.h>
28#include <sqlite3.h>
29#include <ascii-chat/atomic.h>
34#include <ascii-chat/options/options.h> // For MAX_IDENTITY_KEYS
38#include <ascii-chat/discovery/session.h> // For host_lost_candidate_t and MAX_PARTICIPANTS
39
60typedef struct {
64
65 // Crypto handshake state
68
69 // Multi-key session creation state
72 uint8_t pending_session_keys[MAX_IDENTITY_KEYS][32];
74
75 // Transport abstraction
78
79 // Protocol state
82
96
107
115typedef struct {
117
118 // Identity
119 uint8_t identity_public[32];
120 uint8_t identity_secret[64];
121
122 // Persistence (SQLite as single source of truth for sessions)
123 sqlite3 *db;
124
125 // Rate limiting
127
128 // Host migration tracking (in-memory during active migrations)
129 migration_context_t active_migrations[32];
131
132 // Background worker threads (cleanup, etc.)
135
136 // Statistics (TCP + WebSocket)
138
139 // Configuration
142
154
164
174void *acds_client_handler(void *arg);
175
185void *acds_websocket_client_handler(void *arg);
ascii-chat Discovery Service (ACDS) Protocol Message Formats
⚛️ Atomic operations abstraction layer with debug tracking
Common declarations and data structures for cryptographic handshake.
acip_session_create_t
Definition acds.h:221
unsigned long long uint64_t
Definition common.h:59
unsigned char uint8_t
Definition common.h:56
asciichat_error_t
Error and exit codes - unified status values (0-255)
Definition error_codes.h:49
#define MAX_IDENTITY_KEYS
Maximum number of identity keys that can be loaded (for multi-key support)
WebSocket server for accepting browser client connections.
⚙️ Unified options parsing system for ascii-chat with builder pattern and lock-free access
uint8_t session_id[16]
uint8_t participant_id[16]
void * acds_websocket_client_handler(void *arg)
WebSocket client handler (thread entry point)
void * acds_client_handler(void *arg)
Per-client connection handler (thread entry point)
void acds_server_shutdown(acds_server_t *server)
Shutdown discovery server.
asciichat_error_t acds_server_init(acds_server_t *server, const acds_config_t *config)
Initialize discovery server.
ClangTool/LibTooling compatibility shim for stdbool.h.
Per-client connection data.
acip_session_create_t pending_session
Pending session data (from first SESSION_CREATE)
bool handshake_complete
Whether crypto handshake has completed.
int registry_id
Socket or synthetic ID used in tcp_server registry.
crypto_handshake_context_t handshake_ctx
Handshake context for encrypted communication.
bool joined_session
Whether client has successfully joined a session.
size_t num_pending_keys
Number of keys received so far.
acip_transport_t * transport
Persistent transport for this client connection.
bool session_established
True after SESSION_CREATE/SESSION_JOIN completes; handler exits loop.
bool in_multikey_session_create
True during multi-key SESSION_CREATE sequence.
Discovery server configuration.
Discovery server state.
acds_config_t config
Runtime configuration.
atomic_t shutdown
Shutdown flag for worker threads.
size_t num_active_migrations
Number of active migrations.
tcp_server_t * tcp_server
TCP server (owned by server_like)
sqlite3 * db
SQLite database handle.
acds_stats_t stats
Network statistics for all connections.
struct rate_limiter_s * rate_limiter
SQLite-backed rate limiter.
thread_pool_t * worker_pool
Thread pool for background workers.
Network statistics for both TCP and WebSocket connections.
atomic_t packets_received
Total packets received (TCP + WebSocket)
atomic_t packets_sent
Total packets sent (TCP + WebSocket)
atomic_t bytes_sent
Total bytes sent (TCP + WebSocket)
atomic_t bytes_received
Total bytes received (TCP + WebSocket)
time_t start_time
Server start time.
Transport instance structure.
Definition transport.h:214
Atomic value wrapper for integral/boolean types.
Definition atomic.h:76
Cryptographic handshake context structure.
In-memory host migration context.
uint64_t migration_start_ns
When migration started (nanoseconds since sokol_time setup)
Rate limiter structure.
Definition rate_limit.c:64
void thread_pool_t
🧵 Generic thread pool abstraction for managing worker threads
Transport abstraction layer for ACIP protocol.