ascii-chat 0.6.0
Real-time terminal-based video chat with ASCII art conversion
Loading...
Searching...
No Matches
src/client/server.h
Go to the documentation of this file.
1
13#pragma once
14
15#include "platform/socket.h"
16#include "network/packet.h"
17#include "log/logging.h"
18#include <stdint.h>
19#include <stdbool.h>
20
21/* ============================================================================
22 * Connection Error Codes
23 * ============================================================================ */
24
38
39/* ============================================================================
40 * Connection Management Functions
41 * ============================================================================ */
42
50
62int server_connection_establish(const char *address, int port, int reconnect_attempt, bool first_connection,
63 bool has_ever_connected);
64
66
74
82
93
101
108const char *server_connection_get_ip();
109
116void server_connection_set_ip(const char *ip);
117
124
131
138
146
153
167asciichat_error_t threaded_send_packet(packet_type_t type, const void *data, size_t len);
168
179int threaded_send_audio_batch_packet(const float *samples, int num_samples, int batch_count);
180
195asciichat_error_t threaded_send_audio_opus(const uint8_t *opus_data, size_t opus_size, int sample_rate,
196 int frame_duration);
197
212asciichat_error_t threaded_send_audio_opus_batch(const uint8_t *opus_data, size_t opus_size,
213 const uint16_t *frame_sizes, int frame_count);
214
223
232
242
252int threaded_send_terminal_size_with_auto_detect(unsigned short width, unsigned short height);
253
263int threaded_send_client_join_packet(const char *display_name, uint32_t capabilities);
264
265/* ============================================================================
266 * Thread-Safe Packet Sending Functions
267 * ============================================================================ */
268
278int server_send_packet(packet_type_t type, const void *data, size_t len);
279
288int server_send_audio(const float *samples, int num_samples);
289
299int server_send_audio_batch(const float *samples, int num_samples, int batch_count);
300
309int server_send_terminal_capabilities(unsigned short width, unsigned short height);
310
318
326
335
int threaded_send_pong_packet(void)
Thread-safe pong packet transmission.
void server_connection_close()
Close the server connection gracefully.
bool server_connection_is_active()
Check if server connection is currently active.
int server_send_packet(packet_type_t type, const void *data, size_t len)
Send general packet to server.
void server_connection_shutdown()
Emergency connection shutdown for signal handlers.
int server_send_terminal_capabilities(unsigned short width, unsigned short height)
Send terminal capabilities to server.
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.
acip_transport_t * server_connection_get_transport(void)
Get ACIP transport instance.
int threaded_send_stream_start_packet(uint32_t stream_type)
Thread-safe stream start packet transmission.
uint32_t server_connection_get_client_id()
Get client ID assigned by server.
socket_t server_connection_get_socket()
Get current socket file descriptor.
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.
void server_connection_set_transport(acip_transport_t *transport)
Set ACIP transport instance from connection fallback.
void server_connection_set_ip(const char *ip)
Set the server IP address.
int threaded_send_ping_packet(void)
Thread-safe ping packet transmission.
int server_send_stream_start(uint32_t stream_type)
Send stream start notification.
bool server_connection_is_lost()
Check if connection loss has been detected.
int server_send_audio(const float *samples, int num_samples)
Send audio data to server.
int server_connection_init()
Initialize the server connection management subsystem.
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 server_send_audio_batch(const float *samples, int num_samples, int batch_count)
Send batched audio data to server.
asciichat_error_t threaded_send_packet(packet_type_t type, const void *data, size_t len)
Thread-safe packet transmission.
int server_send_stream_stop(uint32_t stream_type)
Send stream stop notification.
int server_send_ping()
Send ping keepalive packet.
int threaded_send_audio_batch_packet(const float *samples, int num_samples, int batch_count)
Thread-safe batched audio packet transmission.
void server_connection_cleanup()
Cleanup connection management subsystem.
int server_send_pong()
Send pong response packet.
void server_connection_lost()
Signal that connection has been lost.
const char * server_connection_get_ip()
Get resolved server IP address.
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.
unsigned short uint16_t
Definition common.h:57
unsigned int uint32_t
Definition common.h:58
unsigned char uint8_t
Definition common.h:56
asciichat_error_t
Error and exit codes - unified status values (0-255)
Definition error_codes.h:46
packet_type_t
Network protocol packet type enumeration.
Definition packet.h:281
int socket_t
Socket handle type (POSIX: int)
Definition socket.h:50
📝 Logging API with multiple log levels and terminal output control
Packet protocol implementation with encryption and compression support.
Cross-platform socket interface for ascii-chat.
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)
Transport instance structure.
Definition transport.h:169