ascii-chat
Binary v0.16.50-198-g78f51665f
Library lib/v0.3.2-2240-g78f51665f
Video chat in your terminal
Loading...
Searching...
No Matches
server/main.h
Go to the documentation of this file.
1
40
41#pragma once
42
43#include <libplatform/atomic.h>
48#include "session/host.h"
49#include <options/options.h>
50#include "stats.h"
51#include "client.h"
52#include "session/h265/server.h"
53
54/* ============================================================================
55 * Global Server State
56 * ============================================================================ */
57
65
73
81
88extern rwlock_t g_client_manager_rwlock;
89
96extern mixer_t *volatile g_audio_mixer;
97
104extern h265_server_context_t *volatile g_h265_server;
105
112
119
127
133extern size_t g_num_server_identity_keys;
134
142
148extern size_t g_num_whitelisted_clients;
149
175typedef struct server_context_t {
176 // Connection runtime
178
179 // Rate limiting
181
182 // Client management
185
186 // Server lifecycle
188
189 // Audio mixing
191
192 // Statistics
194 mutex_t *stats_mutex;
195
196 // Cryptography
201
202 // Session library integration
204
205 // H.265 codec integration
208
234int server_main(void);
atomic_t g_should_exit
Global application exit flag (shared across all modes).
Definition globals.c:31
#define MAX_CLIENTS
Maximum possible clients (static array size) - actual runtime limit set by –max-clients (1-128).
#define MAX_SESSION_KEYS
struct session_host session_host_t
Opaque session host handle.
🏠 Server-side session hosting abstraction
struct network_server network_server_t
Multi-Source Audio Mixing and Processing System.
⚙️ Unified options parsing system for ascii-chat with builder pattern and lock-free access
🚦 Rate limiting API with pluggable backends
struct rate_limiter_s rate_limiter_t
Opaque rate limiter handle.
Definition rate_limit.h:87
size_t g_num_whitelisted_clients
Number of whitelisted clients.
h265_server_context_t *volatile g_h265_server
Global H.265 codec server context.
rate_limiter_t * g_rate_limiter
Global rate limiter for connection attempts and packet processing.
bool g_server_encryption_enabled
Global flag indicating if server encryption is enabled.
mixer_t *volatile g_audio_mixer
Global audio mixer instance for multi-client audio processing.
private_key_t g_server_identity_keys[MAX_SESSION_KEYS]
Global server identity keys array (multi-key support).
public_key_t g_client_whitelist[MAX_CLIENTS]
Global client public key whitelist.
private_key_t g_server_private_key
Global server private key (first identity key, for backward compatibility).
size_t g_num_server_identity_keys
Number of loaded server identity keys.
int server_main(void)
server context keeps the values that move through the subsystem: network_server, rate_limiter,...
rwlock_t g_client_manager_rwlock
Reader-writer lock protecting the global client manager.
client_manager_t g_client_manager
Hash table entry for client packet dispatch.
Per-client state management and lifecycle orchestration.
Server performance statistics tracking.
struct h265_server_context h265_server_context_t
The useful part of h265 client decoder is in client_id, decoder, last_width, last_height: together th...
Server-side H.265 decoding pipeline for multi-client streams.
Atomic value wrapper for integral/boolean types.
Definition atomic.h:76
Global client manager structure for server-side client coordination.
For ducking, this is the live record that ties threshold_dB, leader_margin_dB, atten_dB,...
Definition mixer.h:342
Private identity-key material used for server authentication and signing.
Definition key_types.h:101
The normalized public identity used by ascii-chat's crypto and key-management code.
Definition key_types.h:76
Server context - encapsulates all server state.
session_host_t * session_host
Session host for discovery mode support.
bool encryption_enabled
Whether encryption is enabled.
client_manager_t * client_manager
Client registry and state.
mixer_t * audio_mixer
Multi-client audio mixer.
atomic_t * server_should_exit
Shutdown flag.
size_t num_whitelisted_clients
Number of whitelisted clients.
mutex_t * stats_mutex
Mutex protecting stats.
public_key_t * client_whitelist
Whitelisted client public keys.
h265_server_context_t * h265_server
H.265 decoder pool for all clients.
rwlock_t * client_manager_rwlock
RW lock protecting client manager.
private_key_t * server_private_key
Server's private key.
network_server_t * network_server
Shared connection runtime.
server_stats_t * stats
Server statistics.
rate_limiter_t * rate_limiter
Connection and packet rate limiter.
Counters and rates describing the server's media pipeline.