From f8af4ab3a127fabaf9dc769e1c7a3005a4b35870 Mon Sep 17 00:00:00 2001 From: jake Date: Wed, 15 Jan 2020 07:02:31 -0800 Subject: [PATCH] fix case where unknown packets caused the next packet to not be handled properly --- src/common/client.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/common/client.rs b/src/common/client.rs index 19871b1..b079e82 100644 --- a/src/common/client.rs +++ b/src/common/client.rs @@ -98,8 +98,13 @@ impl Client where let pkt_data = self.incoming_data.drain(..pkt_len).collect::>(); trace!("[recv buf from {:?}] {:?}", self.id, pkt_data); - let pkt = R::from_bytes(&pkt_data[..pkt_size]) - .map_err(|err| -> PacketNetworkError { err.into() })?; + let pkt = match R::from_bytes(&pkt_data[..pkt_size]) { + Ok(p) => p, + Err(err) => { + warn!("error RecvServerPacket::from_bytes: {:?}", err); + continue + }, + }; trace!("[recv from {:?}] {:?}", self.id, pkt); result.push(pkt);