The client main entry point orchestrates the complete client lifecycle including initialization, connection management, reconnection logic, and graceful shutdown.
signal(SIGINT, sigint_handler);
int audio_client_init()
Initialize audio subsystem.
int capture_init()
Initialize capture subsystem.
int display_init()
Initialize what is necessary to display ascii frames.
asciichat_error_t options_init(int argc, char **argv)
Initialize options by parsing command-line arguments.
@ MODE_CLIENT
Client mode - network client options.
ASCIICHAT_API unsigned short int opt_audio_enabled
int reconnect_attempt = 0;
bool first_connection = true;
reconnect_attempt, first_connection,
has_ever_connected);
first_connection = false;
has_ever_connected = true;
reconnect_attempt = 0;
}
}
log_info(
"Connection lost - will attempt reconnection");
}
break;
}
int delay_ms = 10 + (200 * reconnect_attempt);
if (delay_ms > 5000) delay_ms = 5000;
reconnect_attempt++;
}
bool should_exit()
Check if client should exit.
void audio_stop_thread()
Stop audio capture thread.
bool audio_thread_exited()
Check if audio capture thread has exited.
int audio_start_thread()
Start audio capture thread.
int capture_start_thread()
Start capture thread.
void capture_stop_thread()
Stop capture thread.
bool capture_thread_exited()
Check if capture thread has exited.
void server_connection_close()
Close the server connection gracefully.
bool server_connection_is_active()
Check if server connection is currently active.
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.
void display_reset_for_new_connection()
Reset display state for new connection.
bool keepalive_thread_exited()
Check if keepalive thread has exited.
int keepalive_start_thread()
Start keepalive/ping thread.
void keepalive_stop_thread()
Stop keepalive/ping thread.
void protocol_stop_connection()
Stop protocol connection handling.
int protocol_start_connection()
Start protocol connection handling.
bool protocol_connection_lost()
Check if connection has been lost.
#define log_info(...)
Log an INFO message.
ASCIICHAT_API char opt_address[OPTIONS_BUFF_SIZE]
ASCIICHAT_API char opt_port[OPTIONS_BUFF_SIZE]
@ CONNECTION_ERROR_HOST_KEY_FAILED
Host key verification failed (no retry)
@ CONNECTION_ERROR_AUTH_FAILED
Authentication failure (no retry)
@ CONNECTION_WARNING_NO_CLIENT_AUTH
Server not using client verification (warning)