Browse Source

print out packets

pbs
jake 5 years ago
parent
commit
186c3612aa
  1. 7
      src/common/client.rs

7
src/common/client.rs

@ -101,9 +101,11 @@ impl<S, R> Client<S, R> where
let pkt_data = self.incoming_data.drain(..pkt_len).collect::<Vec<_>>(); let pkt_data = self.incoming_data.drain(..pkt_len).collect::<Vec<_>>();
println!("[recv: buf] {:?}", pkt_data);
let pkt = R::from_bytes(&pkt_data[..pkt_size]) let pkt = R::from_bytes(&pkt_data[..pkt_size])
.map_err(|err| -> PacketNetworkError { err.into() })?; .map_err(|err| -> PacketNetworkError { err.into() })?;
println!("[recv] {:?}", pkt);
result.push(pkt); result.push(pkt);
} }
Ok(result) Ok(result)
@ -112,7 +114,12 @@ impl<S, R> Client<S, R> where
pub fn send_pkt(&mut self, pkt: S) { pub fn send_pkt(&mut self, pkt: S) {
println!("[send] {:?}", pkt); println!("[send] {:?}", pkt);
let buf = pkt.as_bytes(); let buf = pkt.as_bytes();
if buf.len() < 1024*2 {
println!("[send: buf] {:?}", buf); println!("[send: buf] {:?}", buf);
}
else {
println!("[send: buf] [...large buffer...]");
}
let mut cbuf = self.cipher_out.encrypt(&buf).unwrap(); let mut cbuf = self.cipher_out.encrypt(&buf).unwrap();
self.send_buffer.append(&mut cbuf); self.send_buffer.append(&mut cbuf);
self.send_data(); self.send_data();

Loading…
Cancel
Save