ascii-chat 0.11.33
Video chat in your terminal
Loading...
Searching...
No Matches
session_client_like_config Struct Reference

#include <src/common/session/client_like.h>

Data Fields

session_client_like_run_fn run_fn
 
void * run_user_data
 
session_client_like_kind_t kind
 
void * discovery
 
bool(* custom_should_exit )(void *user_data)
 
void * exit_user_data
 
int max_reconnect_attempts
 
bool(* should_reconnect_callback )(asciichat_error_t last_error, int attempt_number, void *user_data)
 
void * reconnect_user_data
 
unsigned int reconnect_delay_ms
 
session_keyboard_handler_fn keyboard_handler
 
bool print_newline_on_tty_exit
 

Detailed Description

Configuration for session_client_like_run()

All media, display, audio, FPS, and snapshot settings are read automatically from GET_OPTION() inside the function. Callers only provide the fields below that differ per mode.

Definition at line 112 of file client_like.h.

Field Documentation

◆ custom_should_exit

bool(* session_client_like_config::custom_should_exit) (void *user_data)

Optional additional exit condition. Called in the exit check logic alongside the global should_exit(). The loop exits when EITHER should_exit() OR custom_should_exit() returns true.

Use this for modes that need extra exit logic:

NULL = use only the global should_exit().

Definition at line 153 of file client_like.h.

◆ discovery

void* session_client_like_config::discovery

Active discovery session for this connection (opaque void *). When non-NULL, events will be processed periodically inside the shared exit check, and the session will be stopped during teardown. NULL for mirror mode and TCP client mode. Cast from discovery_session_t * when used (include src/discovery/session.h).

Definition at line 137 of file client_like.h.

Referenced by session_client_like_run().

◆ exit_user_data

void* session_client_like_config::exit_user_data

User data for custom_should_exit callback

Definition at line 156 of file client_like.h.

◆ keyboard_handler

session_keyboard_handler_fn session_client_like_config::keyboard_handler

Keyboard handler for interactive controls (seek, volume, pause, help). Passed directly to session_render_loop(). NULL = no keyboard handling.

Mirror and discovery modes use session_handle_keyboard_input(). Client mode may pass NULL (server drives display).

Definition at line 216 of file client_like.h.

◆ kind

session_client_like_kind_t session_client_like_config::kind

Explicit client-like mode kind.

Definition at line 128 of file client_like.h.

Referenced by session_client_like_run().

◆ max_reconnect_attempts

int session_client_like_config::max_reconnect_attempts

Maximum reconnection attempts. Controls retry behavior: -1 = unlimited retries (keep trying forever) 0 = no retries (single attempt only, exit on failure) >0 = retry up to N times

Default: 0 (no retries). Client mode typically sets to -1. Discovery mode may set custom value based on role.

When run_fn returns non-OK, session_client_like_run() checks this to decide whether to retry or exit.

Definition at line 174 of file client_like.h.

Referenced by session_client_like_run().

◆ print_newline_on_tty_exit

bool session_client_like_config::print_newline_on_tty_exit

When true, write a bare '
' to STDOUT_FILENO on exit if stdout is a TTY. This separates the last rendered ASCII frame from the shell prompt.

Mirror mode: true. Client and discovery modes: false (server/host manages cursor).

Definition at line 229 of file client_like.h.

Referenced by session_client_like_run().

◆ reconnect_delay_ms

unsigned int session_client_like_config::reconnect_delay_ms

Delay in milliseconds before attempting reconnection. Applied after each failed attempt. 0 = no delay.

Can be a fixed value (e.g., 1000 for 1 second) or exponential backoff. Modes with backoff can use should_reconnect_callback to calculate delay based on attempt number.

Definition at line 203 of file client_like.h.

Referenced by session_client_like_run().

◆ reconnect_user_data

void* session_client_like_config::reconnect_user_data

User data for should_reconnect_callback

Definition at line 193 of file client_like.h.

Referenced by session_client_like_run().

◆ run_fn

session_client_like_run_fn session_client_like_config::run_fn

Mode-specific main loop callback (required, never NULL)

Definition at line 118 of file client_like.h.

Referenced by client_main(), mirror_main(), and session_client_like_run().

◆ run_user_data

void* session_client_like_config::run_user_data

User data passed to run_fn

Definition at line 121 of file client_like.h.

Referenced by session_client_like_run().

◆ should_reconnect_callback

bool(* session_client_like_config::should_reconnect_callback) (asciichat_error_t last_error, int attempt_number, void *user_data)

Optional callback to determine if should attempt reconnection.

Called when run_fn returns with error code. Can implement custom reconnection logic:

  • discovery: return false when role changes to prevent retry
  • client: always return true (handled by max_reconnect_attempts)

Should return: true = attempt reconnection false = exit immediately

NULL = always attempt reconnection (unless max_reconnect_attempts reached).

Definition at line 190 of file client_like.h.

Referenced by session_client_like_run().


The documentation for this struct was generated from the following file: