mirror of
https://git.ngram.ca/OpenJam/rc-servers
synced 2026-08-23 23:08:52 +00:00
29 lines
614 B
Rust
29 lines
614 B
Rust
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,
|
||
|
|
}
|