1
0
mirror of https://git.ngram.ca/OpenJam/rc-servers synced 2026-08-23 23:08:52 +00:00

Create first event handler and framework for it

This commit is contained in:
NG (Graham)
2025-07-03 21:53:34 -04:00
parent e69c7dabd6
commit 38ab4ba799
10 changed files with 120 additions and 11 deletions

View File

@@ -0,0 +1,29 @@
pub struct User {
state: tokio::sync::RwLock<UserState>,
}
impl User {
pub fn new() -> Self {
Self {
state: tokio::sync::RwLock::new(UserState::Connecting),
}
}
pub async fn authenticate(&self, info: rlnl::events::loading::GameGuidInfo) -> bool {
*self.state.write().await = UserState::Authenticated(UserInfo {
game: info.game_guid.0,
username: info.player_name.0,
});
true
}
}
enum UserState {
Connecting,
Authenticated(UserInfo),
}
pub struct UserInfo {
pub game: String,
pub username: String,
}