2023-01-31 20:16:23 -06:00
|
|
|
use bincode::{Encode, Decode};
|
2023-02-03 12:36:52 -06:00
|
|
|
use crate::common::ClientId;
|
2023-01-31 20:16:23 -06:00
|
|
|
|
|
|
|
#[repr(u8)]
|
|
|
|
#[derive(Encode, Decode)]
|
|
|
|
pub enum ClientPacket<T> where T: Encode + Decode {
|
2023-02-01 18:54:12 -06:00
|
|
|
Data(T),
|
2023-01-31 20:16:23 -06:00
|
|
|
Connect,
|
|
|
|
Disconnect,
|
|
|
|
Heartbeat,
|
2023-02-01 18:54:12 -06:00
|
|
|
}
|
|
|
|
|
2023-02-03 12:36:52 -06:00
|
|
|
#[derive(Encode, Decode)]
|
|
|
|
pub struct IdClientPacket<T: Encode + Decode>(pub Option<ClientId>, pub ClientPacket<T>);
|
|
|
|
|
2023-02-01 18:54:12 -06:00
|
|
|
#[repr(u8)]
|
|
|
|
#[derive(Encode, Decode)]
|
|
|
|
pub enum ServerPacket<T> where T: Encode + Decode {
|
|
|
|
Data(T),
|
2023-02-03 19:47:09 -06:00
|
|
|
Connected(ClientId),
|
2023-02-04 15:20:19 -06:00
|
|
|
Disconnected(String),
|
2023-01-31 20:16:23 -06:00
|
|
|
}
|
2023-02-03 19:47:09 -06:00
|
|
|
|
|
|
|
#[derive(Encode, Decode)]
|
|
|
|
pub struct IdServerPacket<T: Encode + Decode>(pub Option<ClientId>, pub ServerPacket<T>);
|