-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
replicate: implement server side data model (#121)
Handles serverbound messages and stores state in the server's data model. Does not implement the clientside sync task, or the serverside sync task. Does not attempt to use datagrams yet.
- Loading branch information
Showing
8 changed files
with
209 additions
and
46 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,45 @@ | ||
use std::collections::{HashMap, HashSet}; | ||
|
||
use serde::{Deserialize, Serialize}; | ||
|
||
use crate::data_model::entity::{EntityId, Index, Namespace}; | ||
use crate::{ | ||
data_model::{ | ||
entity::{Index, Namespace}, | ||
State, | ||
}, | ||
ClientId, | ||
}; | ||
|
||
#[derive(Serialize, Deserialize, Eq, PartialEq)] | ||
pub enum Serverbound { | ||
HandshakeRequest, | ||
SpawnEntities { idxs: Vec<Index> }, | ||
HandshakeRequest(ClientId), | ||
SpawnEntities { | ||
// Namespace is implied, clients always spawn on their own namespace | ||
states: HashMap<Index, State>, | ||
}, | ||
UpdateEntities { | ||
namespace: Namespace, | ||
states: HashMap<Index, State>, | ||
}, | ||
DespawnEntities { | ||
namespace: Namespace, | ||
entities: HashSet<Index>, | ||
}, | ||
} | ||
|
||
#[derive(Serialize, Deserialize, Eq, PartialEq)] | ||
pub enum Clientbound { | ||
HandshakeResponse(Namespace), | ||
SpawnEntities { ids: Vec<EntityId> }, | ||
SpawnEntities { | ||
namespace: Namespace, | ||
states: HashMap<Index, State>, | ||
}, | ||
UpdateEntities { | ||
namespace: Namespace, | ||
states: HashMap<Index, State>, | ||
}, | ||
DespawnEntities { | ||
namespace: Namespace, | ||
states: HashSet<Index>, | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters