-
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
25eaf2c
commit e5e9221
Showing
7 changed files
with
74 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
mod init_player; | ||
mod keep_alive; | ||
mod player_join_world; | ||
mod player_kick; | ||
|
||
pub use init_player::init_player; | ||
pub use keep_alive::keep_alive; | ||
pub use player_join_world::player_join_world; | ||
pub use player_kick::player_kick; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
use std::time::Instant; | ||
|
||
use evenio::{prelude::*, rayon::prelude::*}; | ||
use tracing::debug; | ||
|
||
use crate::{Gametick, Player}; | ||
|
||
pub fn keep_alive(_: Receiver<Gametick>, mut fetcher: Fetcher<&mut Player>) { | ||
fetcher.par_iter_mut().for_each(|player| { | ||
// if we haven't sent a keep alive packet in 5 seconds, send one | ||
if player.last_keep_alive_sent.elapsed().as_secs() >= 5 { | ||
player.last_keep_alive_sent = Instant::now(); | ||
// todo: handle and disconnect | ||
let name = &player.name; | ||
debug!("sending keep alive to {name}"); | ||
let _ = player.packets.writer.send_keep_alive(); | ||
} | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters