ascii-chat
Binary v0.16.50-198-g78f51665f
Library lib/v0.3.2-2240-g78f51665f
Video chat in your terminal
Loading...
Searching...
No Matches
src/discovery-service/server.h
Go to the documentation of this file.
1#pragma once
6
8
31
32#include <stdint.h>
33#include <stdbool.h>
34#include <sqlite3.h>
35#include <libplatform/atomic.h>
43#include <ascii-chat/discovery/session.h> // For host_lost_candidate_t and participant storage
44
56typedef struct {
60
61 // Crypto handshake state
63
64 // Multi-key session creation state
68
69 // Transport abstraction
71
72 // Protocol state
77
91
99typedef struct {
103
104 // Identity
107
108 // Persistence (SQLite as single source of truth for sessions)
109 sqlite3 *db;
110
111 // Rate limiting
113
114 // Background worker threads (cleanup, etc.)
117
118 // Statistics (TCP + WebSocket)
120
121 // Configuration
127
142
152
153// Host authority delivery; the transport must carry its joined connection identity.
154void acds_on_host_announcement(const acip_host_announcement_t *, acip_transport_t *, const char *, void *);
156
157void acds_on_host_announcement_ex(const acip_host_announcement_t *announcement, const void *metadata, size_t metadata_length, acip_transport_t *transport, const char *client_ip, void *app_ctx);
ascii-chat Discovery Service (ACDS) Protocol Message Formats
Application limits and constraints.
unsigned char uint8_t
asciichat_error_t
Error and exit codes - unified status values (0-255).
Definition error_codes.h:48
#define SESSION_ID_SIZE
acip_host_announcement_t
Definition acds.h:917
struct acip_transport acip_transport_t
Forward declaration of ACIP transport.
Definition host.h:508
Common declarations and data structures for cryptographic handshake.
Transport abstraction layer for ACIP protocol.
struct network_server network_server_t
struct thread_pool thread_pool_t
One queued function call waiting for a thread-pool worker.
#define ED25519_PUBLIC_KEY_SIZE
Ed25519 public key size in bytes.
Definition sizes.h:37
#define ED25519_PRIVATE_KEY_SIZE
Ed25519 private key size (seed + public) in bytes.
Definition sizes.h:39
const network_connection_callbacks_t acds_network_callbacks
void acds_send_current_host(acds_server_t *, acip_transport_t *, const uint8_t[16])
void acds_on_host_announcement(const acip_host_announcement_t *, acip_transport_t *, const char *, void *)
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)
acds server is intentionally a small, concrete record. Fields such as network_server,...
void acds_on_host_announcement_ex(const acip_host_announcement_t *announcement, const void *metadata, size_t metadata_length, acip_transport_t *transport, const char *client_ip, void *app_ctx)
Network statistics for both TCP and WebSocket connections.
network_negotiation_t negotiation
acds_create_key_set_t create_keys
Pending connection-local key set.
bool joined_session
Whether client has successfully joined a session.
uint8_t participant_id[SESSION_ID_SIZE]
Participant UUID (valid if joined_session).
acip_transport_t * transport
Persistent transport for this client connection.
uint8_t session_id[SESSION_ID_SIZE]
Session UUID (valid if joined_session).
bool session_established
True after SESSION_CREATE/SESSION_JOIN completes; handler exits loop.
Discovery server configuration.
The useful part of acds create key set is in request, count: together they describe what is pending,...
Definition key_set.h:13
Background thread for periodic cleanup.
Discovery server state.
uint8_t identity_secret[ED25519_PRIVATE_KEY_SIZE]
Ed25519 secret key.
acds_config_t config
Runtime configuration.
atomic_t shutdown
Shutdown flag for worker threads.
uint8_t identity_public[ED25519_PUBLIC_KEY_SIZE]
Ed25519 public key.
bool handoff_mutex_initialized
Whether shutdown owns the handoff mutex.
struct acds_handoff_entry * handoffs
sqlite3 * db
SQLite database handle.
network_server_t * network_server
Network runtime owned by server_like.
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.
For acds client data, this is the live record that ties joined_session, negotiation,...
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.
Atomic value wrapper for integral/boolean types.
Definition atomic.h:76
Callbacks and operations used by network connection callbacks. Packet payloads are borrowed until ret...
When code needs to work with network negotiation, it keeps protocol, handshake, identity_keys,...
Definition negotiation.h:18
Private dispatch object joining a rate-limit backend to its operations table.
Definition rate_limit.c:74
🧵 Generic thread pool abstraction for managing worker threads