Expand description
For easy construction of replies to common message types Protocol Response Helpers
This module provides helper functions for handling responses to various protocol operations in the Citadel Protocol. It simplifies the process of sending responses to peer registration, connection, and group invitation requests.
§Features
- Peer registration response handling
- Peer connection response management
- Group invitation response processing
- Automatic ticket management
- Connection type reversal handling
- Username resolution and validation
§Example
use citadel_sdk::prelude::*;
use citadel_sdk::responses;
async fn handle_peer_request<R: Ratchet>(
signal: PeerSignal,
remote: &impl Remote<R>
) -> Result<(), NetworkError> {
// Accept a peer registration request
let ticket = responses::peer_register(signal, true, remote).await?;
Ok(())
}
§Important Notes
- Responses must match request tickets
- Connection types are automatically reversed
- Username resolution is handled internally
- Group responses require server connection
§Related Components
Remote
: Network communication interfacePeerSignal
: Peer communication eventsNodeResult
: Network operation resultsTicket
: Request/response correlation
Functions§
- Given a group invite signal, this function sends a response to the server
- Given the
input_signal
from the peer, this function sends a connect response to the target peer - Given the
input_signal
from the peer, this function sends a register response to the target peer