diff --git a/src/net/mod.rs b/src/net/mod.rs index dd8284a..d49f487 100644 --- a/src/net/mod.rs +++ b/src/net/mod.rs @@ -4,16 +4,18 @@ use serde_json::Value; pub mod server; pub type PlayerId = usize; +pub type PlayerInput = Value; +pub type GameState = Value; #[derive(Deserialize, Debug)] #[serde(tag = "t")] -pub enum ClientMessage { +pub enum ClientMessage { #[serde(rename = "s")] - SetState { s: S }, + SetState { s: GameState }, #[serde(rename = "i")] - Input { i: I }, + Input { i: PlayerInput }, #[serde(rename = "g")] - GetState { c: usize, s: S }, + GetState { c: usize, s: GameState }, } #[derive(Serialize, Debug, Clone)] @@ -24,16 +26,16 @@ pub struct Meta { #[derive(Serialize, Debug, Clone)] #[serde(tag = "t")] -pub enum ServerMessage, S = Value> { +pub enum ServerMessage { #[serde(rename = "m")] Meta { #[serde(flatten)] m: Meta, }, #[serde(rename = "s")] - SetState { u: Option, s: S }, + SetState { u: Option, s: GameState }, #[serde(rename = "i")] - Input { i: I }, + Input { i: Vec }, #[serde(rename = "g")] GetState { c: usize }, }