aboutsummaryrefslogtreecommitdiff
path: root/src/main.rs
blob: d237df095882eb46b1fa2e88b494c67270361754 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
pub mod condition;
pub mod interface;
pub mod protocol;

use crossbeam_channel::{Receiver, Sender};
use interface::network_loop;
use protocol::{ClientboundPacket, ServerboundPacket};
use std::time::Duration;

fn main() {
    let (s, r) = crossbeam_channel::unbounded();
    std::thread::spawn(move || network_loop(s));
    main_loop(r)
}

fn main_loop(packets: Receiver<(u32, ServerboundPacket, Sender<ClientboundPacket>)>) {
    loop {
        for (client_id, packet, responder) in packets.try_iter() {
            println!("{:?}, {:?}, {:?}", client_id, packet, responder);
        }
        std::thread::sleep(Duration::from_secs_f64(10.0 / 30.0));
    }
}