feat!: Refactor, Update to version 2.5.x, Add Battle Scepter

This commit is contained in:
amizing25
2024-09-16 13:10:28 +07:00
parent 88f3025333
commit 6e97b516f4
38 changed files with 722000 additions and 15463 deletions
+3 -2
View File
@@ -1,5 +1,6 @@
use anyhow::Result;
use prost::Message;
use proto::CmdID;
use tokio::{io::AsyncWriteExt, net::TcpStream};
use super::{packet::CommandHandler, NetPacket};
@@ -20,12 +21,12 @@ impl PlayerSession {
}
}
pub async fn send(&mut self, cmd_type: u16, body: impl Message) -> Result<()> {
pub async fn send(&mut self, body: impl Message + CmdID) -> Result<()> {
let mut buf = Vec::new();
body.encode(&mut buf)?;
let payload: Vec<u8> = NetPacket {
cmd_type,
cmd_type: body.get_cmd_id(),
head: Vec::new(),
body: buf,
}