-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
the server can now handle client timeouts
- Loading branch information
1 parent
f16adf0
commit 6399270
Showing
4 changed files
with
132 additions
and
87 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,39 +1,18 @@ | ||
use ferrumc_macros::{packet, NetEncode}; | ||
use std::io::Write; | ||
|
||
#[derive(Debug, NetEncode)] | ||
pub struct KeepAlive { | ||
pub id: i64, | ||
} | ||
|
||
mod adapters { | ||
impl From<i64> for super::KeepAlive { | ||
fn from(id: i64) -> Self { | ||
Self { id } | ||
} | ||
} | ||
} | ||
|
||
#[derive(NetEncode)] | ||
#[packet(packet_id = 0x26)] | ||
pub struct KeepAlivePacket { | ||
pub id: KeepAlive, | ||
pub struct OutgoingKeepAlivePacket { | ||
pub id: i64, | ||
} | ||
|
||
impl Default for KeepAlivePacket { | ||
impl Default for OutgoingKeepAlivePacket { | ||
fn default() -> Self { | ||
let current_ms = std::time::SystemTime::now() | ||
.duration_since(std::time::UNIX_EPOCH) | ||
.expect("Time went backwards?? LMAO") | ||
.as_millis() as i64; | ||
Self::new(current_ms) | ||
} | ||
} | ||
|
||
impl KeepAlivePacket { | ||
pub fn new(id: i64) -> Self { | ||
Self { | ||
id: KeepAlive::from(id), | ||
} | ||
Self { id: current_ms } | ||
} | ||
} |