aboutsummaryrefslogtreecommitdiff
path: root/src/main.rs
blob: 9a84286940c51bb3acd76d2732455be80b214676 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
pub mod condition;
pub mod interface;
pub mod protocol;

use crate::{
    condition::{Condition, Property},
    protocol::Task,
};
use crossbeam_channel::Sender;
use interface::network_loop;
use protocol::{ClientboundPacket, ServerboundPacket};

fn main() {
    network_loop();
}

pub fn handle_packet(client: u32, packet: ServerboundPacket, responder: Sender<ClientboundPacket>) {
    println!("{:?}, {:?}, {:?}", client, packet, responder);
    match packet {
        ServerboundPacket::Download => {
            let _ = responder.send(ClientboundPacket::DownloadResponse(vec![Task {
                name: "blub".to_string(),
                description: "blob".to_string(),
                tags: vec![],
                priority: 69.0,
                completed: None,
                scheduled: None,
                occurence: Some(Condition::And(vec![
                    Condition::Equal {
                        modulus: None,
                        prop: Property::Monthofyear,
                        value: 1,
                    },
                    Condition::Equal {
                        modulus: None,
                        prop: Property::Hour,
                        value: 12,
                    },
                ])),
                deadline: None,
            }]));
        }
    }
}