Update input & state in response to client messages!

This commit is contained in:
Tangent Wantwight 2020-06-08 22:58:42 -04:00
parent 334ecc6eaf
commit ea2770105a

View file

@ -91,8 +91,22 @@ impl Server {
Ok(player_id)
}
pub fn process_message(&mut self, player: usize, msg: ClientMessage) {
pub fn process_message(&mut self, player: PlayerId, msg: ClientMessage) {
trace!("Client#{} message: {:?}", player, &msg);
match msg {
ClientMessage::Input { local_input } => {
if let Some(Some(player)) = self.players.get_mut(player) {
player.input = local_input;
}
}
// for now, anybody can set the state
ClientMessage::SetState { new_state } => self.broadcast(ServerMessage::SetState {
player_id: None,
state: new_state,
}),
ClientMessage::GetState {..} => {}
}
}
fn tick(&mut self, tick: Instant) {