ascii-chat 0.6.0
Real-time terminal-based video chat with ASCII art conversion
Loading...
Searching...
No Matches
client_info Struct Reference

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

#include <lib/network/client.h>

Data Fields

socket_t socket
 
acip_transport_ttransport
 
asciichat_thread_t receive_thread
 
atomic_uint client_id
 
char display_name [MAX_DISPLAY_NAME_LEN]
 
char client_ip [INET_ADDRSTRLEN]
 
int port
 
bool can_send_video
 
bool can_send_audio
 
bool wants_stretch
 
atomic_bool is_sending_video
 
atomic_bool is_sending_audio
 
void * opus_decoder
 
terminal_capabilities_t terminal_caps
 
bool has_terminal_caps
 
char client_palette_chars [256]
 
size_t client_palette_len
 
char client_luminance_palette [256]
 
palette_type_t client_palette_type
 
bool client_palette_initialized
 
atomic_ushort width
 
atomic_ushort height
 
atomic_bool active
 
atomic_bool shutting_down
 
atomic_bool protocol_disconnect_requested
 
time_t connected_at
 
uint64_t frames_sent
 
uint64_t frames_received
 
uint32_t frames_received_logged
 
video_frame_buffer_tincoming_video_buffer
 
audio_ring_buffer_tincoming_audio_buffer
 
video_frame_buffer_toutgoing_video_buffer
 
packet_queue_taudio_queue
 
asciichat_thread_t send_thread
 
atomic_bool send_thread_running
 
atomic_int last_rendered_grid_sources
 
atomic_int last_sent_grid_sources
 
void * send_buffer
 
size_t send_buffer_size
 
void * crypto_plaintext_buffer
 
size_t crypto_plaintext_size
 
void * crypto_ciphertext_buffer
 
size_t crypto_ciphertext_size
 
asciichat_thread_t video_render_thread
 
asciichat_thread_t audio_render_thread
 
atomic_bool video_render_thread_running
 
atomic_bool audio_render_thread_running
 
struct timespec last_video_render_time
 
struct timespec last_audio_render_time
 
mutex_t client_state_mutex
 
mutex_t send_mutex
 
crypto_handshake_context_t crypto_handshake_ctx
 
bool crypto_initialized
 
packet_type_t pending_packet_type
 
void * pending_packet_payload
 
size_t pending_packet_length
 
UT_hash_handle hh
 

Detailed Description

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.

Definition at line 77 of file lib/network/client.h.

Field Documentation

◆ active

◆ audio_queue

◆ audio_render_thread

asciichat_thread_t client_info::audio_render_thread

Definition at line 147 of file lib/network/client.h.

Referenced by stop_client_render_threads().

◆ audio_render_thread_running

atomic_bool client_info::audio_render_thread_running

◆ can_send_audio

bool client_info::can_send_audio

Definition at line 88 of file lib/network/client.h.

Referenced by handle_client_join_packet().

◆ can_send_video

bool client_info::can_send_video

Definition at line 87 of file lib/network/client.h.

Referenced by handle_client_join_packet().

◆ client_id

◆ client_ip

char client_info::client_ip[INET_ADDRSTRLEN]

Definition at line 83 of file lib/network/client.h.

Referenced by process_decrypted_packet().

◆ client_luminance_palette

char client_info::client_luminance_palette[256]

Definition at line 103 of file lib/network/client.h.

Referenced by handle_client_capabilities_packet().

◆ client_palette_chars

char client_info::client_palette_chars[256]

Definition at line 101 of file lib/network/client.h.

Referenced by handle_client_capabilities_packet().

◆ client_palette_initialized

bool client_info::client_palette_initialized

Definition at line 105 of file lib/network/client.h.

Referenced by handle_client_capabilities_packet().

◆ client_palette_len

size_t client_info::client_palette_len

Definition at line 102 of file lib/network/client.h.

Referenced by handle_client_capabilities_packet().

◆ client_palette_type

palette_type_t client_info::client_palette_type

Definition at line 104 of file lib/network/client.h.

Referenced by handle_client_capabilities_packet().

◆ client_state_mutex

◆ connected_at

time_t client_info::connected_at

Definition at line 114 of file lib/network/client.h.

◆ crypto_ciphertext_buffer

void* client_info::crypto_ciphertext_buffer

Definition at line 142 of file lib/network/client.h.

◆ crypto_ciphertext_size

size_t client_info::crypto_ciphertext_size

Definition at line 143 of file lib/network/client.h.

◆ crypto_handshake_ctx

◆ crypto_initialized

◆ crypto_plaintext_buffer

void* client_info::crypto_plaintext_buffer

Definition at line 140 of file lib/network/client.h.

◆ crypto_plaintext_size

size_t client_info::crypto_plaintext_size

Definition at line 141 of file lib/network/client.h.

◆ display_name

◆ frames_received

uint64_t client_info::frames_received

Definition at line 116 of file lib/network/client.h.

Referenced by handle_image_frame_packet().

◆ frames_received_logged

uint32_t client_info::frames_received_logged

Definition at line 117 of file lib/network/client.h.

Referenced by handle_image_frame_packet().

◆ frames_sent

uint64_t client_info::frames_sent

Definition at line 115 of file lib/network/client.h.

Referenced by update_server_stats().

◆ has_terminal_caps

bool client_info::has_terminal_caps

◆ height

atomic_ushort client_info::height

◆ hh

UT_hash_handle client_info::hh

Definition at line 171 of file lib/network/client.h.

◆ incoming_audio_buffer

◆ incoming_video_buffer

video_frame_buffer_t* client_info::incoming_video_buffer

◆ is_sending_audio

atomic_bool client_info::is_sending_audio

◆ is_sending_video

atomic_bool client_info::is_sending_video

◆ last_audio_render_time

struct timespec client_info::last_audio_render_time

Definition at line 153 of file lib/network/client.h.

◆ last_rendered_grid_sources

atomic_int client_info::last_rendered_grid_sources

Definition at line 134 of file lib/network/client.h.

Referenced by client_send_thread_func(), and client_video_render_thread().

◆ last_sent_grid_sources

atomic_int client_info::last_sent_grid_sources

Definition at line 135 of file lib/network/client.h.

Referenced by client_send_thread_func().

◆ last_video_render_time

struct timespec client_info::last_video_render_time

Definition at line 152 of file lib/network/client.h.

◆ opus_decoder

◆ outgoing_video_buffer

◆ pending_packet_length

size_t client_info::pending_packet_length

Definition at line 168 of file lib/network/client.h.

Referenced by server_crypto_handshake().

◆ pending_packet_payload

void* client_info::pending_packet_payload

Definition at line 167 of file lib/network/client.h.

Referenced by server_crypto_handshake().

◆ pending_packet_type

packet_type_t client_info::pending_packet_type

Definition at line 166 of file lib/network/client.h.

Referenced by server_crypto_handshake().

◆ port

int client_info::port

Definition at line 84 of file lib/network/client.h.

◆ protocol_disconnect_requested

atomic_bool client_info::protocol_disconnect_requested

Definition at line 113 of file lib/network/client.h.

Referenced by client_receive_thread(), and disconnect_client_for_bad_data().

◆ receive_thread

asciichat_thread_t client_info::receive_thread

Definition at line 80 of file lib/network/client.h.

Referenced by stop_client_threads().

◆ send_buffer

void* client_info::send_buffer

Definition at line 138 of file lib/network/client.h.

Referenced by cleanup_client_media_buffers().

◆ send_buffer_size

size_t client_info::send_buffer_size

Definition at line 139 of file lib/network/client.h.

Referenced by cleanup_client_media_buffers().

◆ send_mutex

◆ send_thread

asciichat_thread_t client_info::send_thread

Definition at line 130 of file lib/network/client.h.

Referenced by stop_client_threads().

◆ send_thread_running

atomic_bool client_info::send_thread_running

◆ shutting_down

atomic_bool client_info::shutting_down

◆ socket

◆ terminal_caps

terminal_capabilities_t client_info::terminal_caps

◆ transport

◆ video_render_thread

asciichat_thread_t client_info::video_render_thread

Definition at line 146 of file lib/network/client.h.

Referenced by stop_client_render_threads().

◆ video_render_thread_running

atomic_bool client_info::video_render_thread_running

◆ wants_stretch

bool client_info::wants_stretch

Definition at line 89 of file lib/network/client.h.

Referenced by handle_client_join_packet().

◆ width

atomic_ushort client_info::width

The documentation for this struct was generated from the following file: