From 88596830743c359feb30cc1d40f956809dd7acb0 Mon Sep 17 00:00:00 2001 From: Joshua Goins Date: Mon, 17 Mar 2025 17:17:19 -0400 Subject: [PATCH] Document the various LobbyConnection functions, move it up to it's super module --- src/bin/kawari-lobby.rs | 2 +- src/lobby/connection.rs | 7 ++++++- src/lobby/mod.rs | 5 ++++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/bin/kawari-lobby.rs b/src/bin/kawari-lobby.rs index 4d8a5d8..ce0918d 100644 --- a/src/bin/kawari-lobby.rs +++ b/src/bin/kawari-lobby.rs @@ -1,5 +1,5 @@ +use kawari::lobby::LobbyConnection; use kawari::lobby::chara_make::CharaMake; -use kawari::lobby::connection::LobbyConnection; use kawari::lobby::ipc::{ CharacterDetails, ClientLobbyIpcData, LobbyCharacterActionKind, ServerLobbyIpcData, ServerLobbyIpcSegment, ServerLobbyIpcType, diff --git a/src/lobby/connection.rs b/src/lobby/connection.rs index c39bb3f..8f7bfbd 100644 --- a/src/lobby/connection.rs +++ b/src/lobby/connection.rs @@ -22,7 +22,7 @@ use super::{ }; use crate::lobby::ipc::ClientLobbyIpcSegment; -/// Represents a single connection between an instance of the client and the lobby server +/// Represents a single connection between an instance of the client and the lobby server. pub struct LobbyConnection { pub socket: TcpStream, @@ -49,6 +49,7 @@ impl LobbyConnection { .await; } + /// Send an acknowledgement to the client that we generated a valid encryption key. pub async fn initialize_encryption(&mut self, phrase: &str, key: &[u8; 4]) { // Generate an encryption key for this client self.state.client_key = Some(generate_encryption_key(key, phrase)); @@ -67,6 +68,7 @@ impl LobbyConnection { .await; } + /// Send the service account list to the client. pub async fn send_account_list(&mut self) { // send the client the service account list let service_accounts = [ServiceAccount { @@ -103,6 +105,7 @@ impl LobbyConnection { .await; } + /// Send the world, retainer and character list to the client. pub async fn send_lobby_info(&mut self, sequence: u64) { let mut packets = Vec::new(); // send them the server list @@ -289,6 +292,7 @@ impl LobbyConnection { } } + /// Send the host information for the world server to the client. pub async fn send_enter_world(&mut self, sequence: u64, lookup_id: u64) { let Some(session_id) = &self.session_id else { panic!("Missing session id!"); @@ -320,6 +324,7 @@ impl LobbyConnection { .await; } + /// Send a lobby error to the client. pub async fn send_error(&mut self, sequence: u64, error: u32, exd_error: u16) { let lobby_error = ServerLobbyIpcData::LobbyError { sequence, diff --git a/src/lobby/mod.rs b/src/lobby/mod.rs index 40ce1d0..2a29263 100644 --- a/src/lobby/mod.rs +++ b/src/lobby/mod.rs @@ -1,4 +1,7 @@ pub mod chara_make; mod client_select_data; -pub mod connection; + +mod connection; +pub use connection::LobbyConnection; + pub mod ipc;