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

ascii-chat Client Server Connection Management Interface More...

Go to the source code of this file.

Enumerations

enum  connection_error_t {
  CONNECTION_SUCCESS = 0 , CONNECTION_WARNING_NO_CLIENT_AUTH = 1 , CONNECTION_ERROR_GENERIC = -1 , CONNECTION_ERROR_AUTH_FAILED = -2 ,
  CONNECTION_ERROR_HOST_KEY_FAILED = -3
}
 Connection establishment error codes. More...
 

Functions

int server_connection_init ()
 Initialize the server connection management subsystem.
 
int server_connection_establish (const char *address, int port, int reconnect_attempt, bool first_connection, bool has_ever_connected)
 Establish connection to ascii-chat server.
 
bool server_connection_is_active ()
 Check if server connection is currently active.
 
socket_t server_connection_get_socket ()
 Get current socket file descriptor.
 
acip_transport_tserver_connection_get_transport (void)
 Get ACIP transport instance.
 
void server_connection_set_transport (acip_transport_t *transport)
 Set ACIP transport instance from connection fallback.
 
uint32_t server_connection_get_client_id ()
 Get client ID assigned by server.
 
const char * server_connection_get_ip ()
 Get resolved server IP address.
 
void server_connection_set_ip (const char *ip)
 Set the server IP address.
 
void server_connection_close ()
 Close the server connection gracefully.
 
void server_connection_shutdown ()
 Emergency connection shutdown for signal handlers.
 
void server_connection_lost ()
 Signal that connection has been lost.
 
bool server_connection_is_lost ()
 Check if connection loss has been detected.
 
void server_connection_cleanup ()
 Cleanup connection management subsystem.
 
asciichat_error_t threaded_send_packet (packet_type_t type, const void *data, size_t len)
 Thread-safe packet transmission.
 
int threaded_send_audio_batch_packet (const float *samples, int num_samples, int batch_count)
 Thread-safe batched audio packet transmission.
 
asciichat_error_t threaded_send_audio_opus (const uint8_t *opus_data, size_t opus_size, int sample_rate, int frame_duration)
 Thread-safe Opus audio frame transmission.
 
asciichat_error_t threaded_send_audio_opus_batch (const uint8_t *opus_data, size_t opus_size, const uint16_t *frame_sizes, int frame_count)
 Thread-safe Opus audio batch packet transmission.
 
int threaded_send_ping_packet (void)
 Thread-safe ping packet transmission.
 
int threaded_send_pong_packet (void)
 Thread-safe pong packet transmission.
 
int threaded_send_stream_start_packet (uint32_t stream_type)
 Thread-safe stream start packet transmission.
 
int threaded_send_terminal_size_with_auto_detect (unsigned short width, unsigned short height)
 Thread-safe terminal size packet transmission with auto-detection.
 
int threaded_send_client_join_packet (const char *display_name, uint32_t capabilities)
 Thread-safe client join packet transmission.
 
int server_send_packet (packet_type_t type, const void *data, size_t len)
 Send general packet to server.
 
int server_send_audio (const float *samples, int num_samples)
 Send audio data to server.
 
int server_send_audio_batch (const float *samples, int num_samples, int batch_count)
 Send batched audio data to server.
 
int server_send_terminal_capabilities (unsigned short width, unsigned short height)
 Send terminal capabilities to server.
 
int server_send_ping ()
 Send ping keepalive packet.
 
int server_send_pong ()
 Send pong response packet.
 
int server_send_stream_start (uint32_t stream_type)
 Send stream start notification.
 
int server_send_stream_stop (uint32_t stream_type)
 Send stream stop notification.
 

Detailed Description

ascii-chat Client Server Connection Management Interface

Provides connection establishment, management, and thread-safe packet transmission functions for communicating with ascii-chat servers.

Author
Zachary Fogg me@zf.nosp@m.o.gg
Date
2025

Definition in file src/client/server.h.

Enumeration Type Documentation

◆ connection_error_t

Connection establishment error codes.

These codes are returned by server_connection_establish() to indicate different failure modes. Zero indicates success.

Enumerator
CONNECTION_SUCCESS 

Connection established successfully.

CONNECTION_WARNING_NO_CLIENT_AUTH 

Server not using client verification (warning)

CONNECTION_ERROR_GENERIC 

Generic error (retry allowed)

CONNECTION_ERROR_AUTH_FAILED 

Authentication failure (no retry)

CONNECTION_ERROR_HOST_KEY_FAILED 

Host key verification failed (no retry)

Definition at line 31 of file src/client/server.h.

31 {
connection_error_t
Connection establishment error codes.
@ CONNECTION_ERROR_GENERIC
Generic error (retry allowed)
@ CONNECTION_ERROR_HOST_KEY_FAILED
Host key verification failed (no retry)
@ CONNECTION_SUCCESS
Connection established successfully.
@ CONNECTION_ERROR_AUTH_FAILED
Authentication failure (no retry)
@ CONNECTION_WARNING_NO_CLIENT_AUTH
Server not using client verification (warning)