ascii-chat 0.6.0
Real-time terminal-based video chat with ASCII art conversion
Loading...
Searching...
No Matches
client.h File Reference

Client state structure and network logging macros. More...

Go to the source code of this file.

Data Structures

struct  client_info
 Per-client state structure for server-side client management. More...
 

Typedefs

typedef struct client_info client_info_t
 Per-client state structure for server-side client management.
 

Detailed Description

Client state structure and network logging macros.

This header defines the client_info_t structure used by both library code and server code. It also provides convenience macros for network logging.

Definition in file lib/network/client.h.

Typedef Documentation

◆ client_info_t

typedef struct client_info client_info_t

Per-client state structure for server-side client management.

Represents complete state for a single connected client in the ascii-chat server. This structure stores all client-specific information including network connection, media capabilities, terminal settings, threading state, and synchronization primitives.

CORE FIELDS:

  • Network: Socket, IP address, port, thread handles
  • Media: Video/audio capabilities, stream state, buffers
  • Terminal: Capabilities, palette cache, dimensions
  • Threading: Send/receive/render thread handles and flags
  • Synchronization: Mutexes for thread-safe state access
  • Crypto: Cryptographic handshake context for secure communication

THREADING MODEL:

Each client has dedicated threads:

  • receive_thread: Handles incoming packets (protocol processing)
  • send_thread: Manages outgoing packet delivery (packet queues)
  • video_render_thread: Generates ASCII frames at 60fps
  • audio_render_thread: Mixes audio streams at 172fps

BUFFER MANAGEMENT:

  • incoming_video_buffer: Double-buffered video frames from client
  • incoming_audio_buffer: Ring buffer for client's audio samples
  • outgoing_video_buffer: Double-buffered ASCII frames to send
  • audio_queue: Packet queue for audio packets to send

MEMORY MANAGEMENT:

  • Pre-allocated buffers to avoid malloc/free in hot paths
  • send_buffer: For packet assembly
  • crypto_plaintext_buffer: For encryption plaintext
  • crypto_ciphertext_buffer: For encryption ciphertext
Note
All atomic fields are thread-safe for concurrent access.
Buffer pointers are set once during client creation and never change.
Thread handles are valid only when threads are running.