ascii-chat 0.11.33
Video chat in your terminal
Loading...
Searching...
No Matches
src/client/server.h
Go to the documentation of this file.
1
13#pragma once
14
17#include <ascii-chat/log/log.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
121int server_connection_establish(const char *address, int port, int reconnect_attempt, bool first_connection,
122 bool has_ever_connected);
123
125
133
141
151void server_connection_set_transport(struct acip_transport *transport);
152
160
167const char *server_connection_get_ip();
168
175void server_connection_set_ip(const char *ip);
176
183void server_connection_set_port(int port);
184
192
199
206
213
221
228
242asciichat_error_t threaded_send_packet(packet_type_t type, const void *data, size_t len);
243
254int threaded_send_audio_batch_packet(const float *samples, int num_samples, int batch_count);
255
270asciichat_error_t threaded_send_audio_opus(const uint8_t *opus_data, size_t opus_size, int sample_rate,
271 int frame_duration);
272
287asciichat_error_t threaded_send_audio_opus_batch(const uint8_t *opus_data, size_t opus_size,
288 const uint16_t *frame_sizes, int frame_count);
289
304asciichat_error_t threaded_send_image_frame(const void *pixel_data, uint32_t width, uint32_t height,
305 uint32_t pixel_format);
306
321asciichat_error_t threaded_send_image_frame_h265(const void *pixel_data, uint32_t width, uint32_t height);
322
331
340
350
360asciichat_error_t threaded_send_terminal_size_with_auto_detect(unsigned short width, unsigned short height);
361
371int threaded_send_client_join_packet(const char *display_name, uint32_t capabilities);
372
373/* ============================================================================
374 * Thread-Safe Packet Sending Functions
375 * ============================================================================ */
376
386int server_send_packet(packet_type_t type, const void *data, size_t len);
387
396int server_send_audio(const float *samples, int num_samples);
397
407int server_send_audio_batch(const float *samples, int num_samples, int batch_count);
408
417int server_send_terminal_capabilities(unsigned short width, unsigned short height);
418
426
434
443
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.
asciichat_error_t threaded_send_image_frame(const void *pixel_data, uint32_t width, uint32_t height, uint32_t pixel_format)
Thread-safe image frame transmission.
int server_send_terminal_capabilities(unsigned short width, unsigned short height)
Send terminal capabilities to server.
asciichat_error_t 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.
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_image_frame_h265(const void *pixel_data, uint32_t width, uint32_t height)
Send H.265-encoded video frame to server (thread-safe)
asciichat_error_t threaded_send_packet(packet_type_t type, const void *data, size_t len)
Thread-safe packet transmission.
void server_connection_set_port(int port)
Set the server port.
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.
asciichat_error_t threaded_send_stream_start_packet(uint32_t stream_type)
Thread-safe stream start packet transmission.
int server_send_pong()
Send pong response packet.
void server_connection_lost()
Signal that connection has been lost.
int server_connection_get_port(void)
Get the server port.
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:49
packet_type_t
Network protocol packet type enumeration.
Definition packet.h:286
int socket_t
📝 Logging API with multiple log levels and terminal output control
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)
ClangTool/LibTooling compatibility shim for stdbool.h.
Transport instance structure.
Definition transport.h:214