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:
29
rc_multiplayer/src/user.rs
Normal file
29
rc_multiplayer/src/user.rs
Normal 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,
|
||||
}
|
||||
Reference in New Issue
Block a user