Force packet resizing on broadcast

This commit is contained in:
Jack Garrard
2022-08-08 02:50:06 -07:00
parent 9d8dff6f82
commit 75246d0005
2 changed files with 6 additions and 1 deletions

View File

@@ -254,7 +254,8 @@ impl Coordinator {
unimplemented!()
}
async fn broadcast(&mut self, p: Packet) -> Result<()> {
async fn broadcast(&mut self, mut p: Packet) -> Result<()> {
p.resize();
for cli in &mut self.to_clients.values() {
cli.send(Command::Packet(p.clone())).await?;
}

View File

@@ -38,6 +38,10 @@ impl Packet {
}
}
pub fn resize(&mut self) {
self.data_size = self.data.get_size() as u16;
}
pub fn check(buf: &mut Cursor<&[u8]>) -> Result<u64> {
let header_size = 16 + 2;
let start_pos = buf.position();