packet decoding and game message encoding

This commit is contained in:
Wiktor Mazur
2019-08-04 19:20:41 +02:00
parent 6b7d1e2905
commit d8b558055a
7 changed files with 91 additions and 12 deletions
+8 -2
View File
@@ -9,7 +9,7 @@ use std::sync::mpsc;
use packet_sniffer::UdpPacket;
mod protocol;
mod game_protocol;
fn main() {
let (tx, rx): (Sender<UdpPacket>, Receiver<UdpPacket>) = mpsc::channel();
@@ -21,7 +21,13 @@ fn main() {
if packet.destination_port != 5056 && packet.source_port != 5056 {
continue;
}
protocol::decode(&packet.payload);
let messages = game_protocol::decode(&packet.payload);
for msg in messages {
if let game_protocol::Message::ChatSay(m) = msg {
println!("Found message {:?}", m);
}
}
}