|
ascii-chat 0.8.38
Real-time terminal-based video chat with ASCII art conversion
|
TCP connection handler for client mode. More...
Go to the source code of this file.
Functions | |
| const char * | connection_state_name (connection_state_t state) |
| Get human-readable state name for logging. | |
| asciichat_error_t | connection_context_init (connection_attempt_context_t *ctx) |
| Initialize connection attempt context. | |
| void | connection_context_cleanup (connection_attempt_context_t *ctx) |
| Cleanup connection attempt context. | |
| asciichat_error_t | connection_state_transition (connection_attempt_context_t *ctx, connection_state_t new_state) |
| Transition to next connection state with validation. | |
| bool | connection_check_timeout (const connection_attempt_context_t *ctx) |
| Check if connection attempt has exceeded timeout. | |
| asciichat_error_t | connection_attempt_tcp (connection_attempt_context_t *ctx, const char *server_address, uint16_t server_port, struct tcp_client *pre_created_tcp_client) |
| Attempt direct TCP connection. | |
| asciichat_error_t | connection_attempt_websocket (connection_attempt_context_t *ctx, const char *ws_url) |
| Attempt WebSocket connection (ws:// or wss://) | |
TCP connection handler for client mode.
Implements direct TCP connection for client mode. Client mode uses direct TCP connections only - no WebRTC fallback.
Features:
Integration Points:
Definition in file connection_attempt.c.
| asciichat_error_t connection_attempt_tcp | ( | connection_attempt_context_t * | ctx, |
| const char * | server_address, | ||
| uint16_t | server_port, | ||
| struct tcp_client * | pre_created_tcp_client | ||
| ) |
Attempt direct TCP connection.
Attempt TCP connection.
Connects to server via TCP, performs crypto handshake if enabled, and creates ACIP transport for protocol communication.
Definition at line 177 of file connection_attempt.c.
References acip_tcp_transport_create(), connection_attempt_context_t::active_transport, connection_attempt_context_t::attempt_start_time_ns, client_crypto_handshake(), client_crypto_init(), client_crypto_set_mode(), CONN_STATE_ATTEMPTING, CONN_STATE_CONNECTED, CONN_STATE_FAILED, CONN_TIMEOUT_TCP, connection_state_transition(), crypto_client_get_context(), crypto_client_is_ready(), connection_attempt_context_t::reconnect_attempt, server_connection_set_ip(), should_exit(), tcp_client_connect(), tcp_client_create(), tcp_client_destroy(), tcp_client_get_socket(), connection_attempt_context_t::tcp_client_instance, time_get_realtime_ns(), connection_attempt_context_t::timeout_ns, url_is_websocket(), url_parse(), url_parts_destroy(), websocket_client_connect(), websocket_client_create(), websocket_client_destroy(), and connection_attempt_context_t::ws_client_instance.
| asciichat_error_t connection_attempt_websocket | ( | connection_attempt_context_t * | ctx, |
| const char * | ws_url | ||
| ) |
Attempt WebSocket connection (ws:// or wss://)
Attempt WebSocket connection.
Connects to server via WebSocket, performs crypto handshake if enabled, and creates ACIP transport for protocol communication.
Definition at line 423 of file connection_attempt.c.
References connection_attempt_context_t::active_transport, connection_attempt_context_t::attempt_start_time_ns, client_crypto_init(), CONN_STATE_ATTEMPTING, CONN_STATE_CONNECTED, CONN_STATE_FAILED, CONN_TIMEOUT_TCP, connection_state_transition(), crypto_client_get_context(), crypto_client_is_ready(), should_exit(), time_get_realtime_ns(), connection_attempt_context_t::timeout_ns, websocket_client_connect(), websocket_client_create(), websocket_client_destroy(), and connection_attempt_context_t::ws_client_instance.
| bool connection_check_timeout | ( | const connection_attempt_context_t * | ctx | ) |
Check if connection attempt has exceeded timeout.
Compares elapsed time since attempt start against timeout.
| ctx | Connection context |
Definition at line 152 of file connection_attempt.c.
References connection_attempt_context_t::attempt_start_time_ns, time_get_realtime_ns(), and connection_attempt_context_t::timeout_ns.
| void connection_context_cleanup | ( | connection_attempt_context_t * | ctx | ) |
Cleanup connection attempt context.
Closes and releases any active transports, frees WebRTC peer manager. Called on connection success, failure, or shutdown.
| ctx | Connection context to cleanup |
Definition at line 102 of file connection_attempt.c.
References acip_transport_destroy(), connection_attempt_context_t::active_transport, tcp_client_destroy(), connection_attempt_context_t::tcp_client_instance, websocket_client_destroy(), and connection_attempt_context_t::ws_client_instance.
Referenced by client_main().
| asciichat_error_t connection_context_init | ( | connection_attempt_context_t * | ctx | ) |
Initialize connection attempt context.
Sets up initial state, resets timeouts, and prepares for connection attempt.
| ctx | Connection context to initialize |
Definition at line 74 of file connection_attempt.c.
References connection_attempt_context_t::attempt_start_time_ns, CONN_STATE_IDLE, CONN_TIMEOUT_TCP, connection_attempt_context_t::current_state, connection_attempt_context_t::previous_state, connection_attempt_context_t::reconnect_attempt, time_get_realtime_ns(), connection_attempt_context_t::timeout_ns, and connection_attempt_context_t::total_transitions.
Referenced by client_main().
| const char * connection_state_name | ( | connection_state_t | state | ) |
Get human-readable state name for logging.
| state | Connection state |
Definition at line 50 of file connection_attempt.c.
References CONN_STATE_ATTEMPTING, CONN_STATE_CONNECTED, CONN_STATE_DISCONNECTED, CONN_STATE_FAILED, and CONN_STATE_IDLE.
Referenced by connection_state_transition().
| asciichat_error_t connection_state_transition | ( | connection_attempt_context_t * | ctx, |
| connection_state_t | new_state | ||
| ) |
Transition to next connection state with validation.
Transition to next connection state.
Definition at line 134 of file connection_attempt.c.
References connection_state_name(), connection_attempt_context_t::current_state, connection_attempt_context_t::previous_state, and connection_attempt_context_t::total_transitions.
Referenced by connection_attempt_tcp(), and connection_attempt_websocket().