|
ascii-chat 0.8.38
Real-time terminal-based video chat with ASCII art conversion
|
Integration helpers for session consensus in discovery mode. More...
Go to the source code of this file.
Functions | |
| asciichat_error_t | consensus_get_discovery_callbacks (void *context, session_consensus_callbacks_t *out_callbacks) |
| Get callbacks configured for discovery mode integration. | |
| asciichat_error_t | consensus_create_for_discovery (const uint8_t session_id[16], const uint8_t my_id[16], const uint8_t participant_ids[64][16], int num_participants, void *discovery_context, session_consensus_t **out_consensus) |
| Example: Create session consensus for discovery mode. | |
| uint32_t | consensus_suggest_timeout_ms (session_consensus_t *consensus, uint32_t current_timeout_ms) |
| Calculate how long to wait until next consensus processing. | |
Integration helpers for session consensus in discovery mode.
This file provides example integration code showing how modes (discovery, server, client, acds) can integrate the ring consensus abstraction.
Design Example for Discovery Mode:
Definition in file consensus_integration.c.
| asciichat_error_t consensus_create_for_discovery | ( | const uint8_t | session_id[16], |
| const uint8_t | my_id[16], | ||
| const uint8_t | participant_ids[64][16], | ||
| int | num_participants, | ||
| void * | discovery_context, | ||
| session_consensus_t ** | out_consensus | ||
| ) |
Example: Create session consensus for discovery mode.
Shows how a mode would create the consensus abstraction. This is a standalone example - real discovery session would call this when transitioning to ACTIVE state if participants found.
| session_id | Session identifier (16 bytes) |
| my_id | My participant identifier (16 bytes) |
| participant_ids | Array of all participant IDs (up to 64) |
| num_participants | Count of participants |
| discovery_context | Mode-specific context (e.g., discovery_session_t) |
| out_consensus | Output: Created consensus handle |
Definition at line 159 of file consensus_integration.c.
References consensus_get_discovery_callbacks(), session_consensus_create(), and session_id.
| asciichat_error_t consensus_get_discovery_callbacks | ( | void * | context, |
| session_consensus_callbacks_t * | out_callbacks | ||
| ) |
Get callbacks configured for discovery mode integration.
Returns a properly configured callback structure for session consensus. The returned callbacks encapsulate the discovery session's packet sending, election handling, and metrics measurement capabilities.
| context | Discovery session pointer (void* for genericity) |
| out_callbacks | Output: Configured callbacks |
Definition at line 129 of file consensus_integration.c.
Referenced by consensus_create_for_discovery().
| uint32_t consensus_suggest_timeout_ms | ( | session_consensus_t * | consensus, |
| uint32_t | current_timeout_ms | ||
| ) |
Calculate how long to wait until next consensus processing.
Useful for modes to schedule when they should call consensus_process() next.
| consensus | Consensus handle |
| current_timeout_ms | Current event loop timeout in milliseconds |
Definition at line 196 of file consensus_integration.c.
References session_consensus_time_until_next_round().