From 522d9cca3382bd4f9cd5e2340d144c5ba8d4432e Mon Sep 17 00:00:00 2001 From: Kayh Date: Sat, 18 Nov 2023 14:06:22 -0500 Subject: [PATCH] setup world server --- server/Cargo.toml | 3 ++- server/README.md | 33 ++++++++++++++------------------- server/src/main.rs | 7 +++++++ server/src/world/mod.rs | 6 ++++++ 4 files changed, 29 insertions(+), 20 deletions(-) create mode 100644 server/src/world/mod.rs diff --git a/server/Cargo.toml b/server/Cargo.toml index f58b901d0..cd7049e8a 100644 --- a/server/Cargo.toml +++ b/server/Cargo.toml @@ -16,9 +16,10 @@ leptos_axum = { version = "0.5.1", optional = true } unavi-web-app = { path = "../web/app", features = ["ssr"], optional = true } [features] -default = ["web"] +default = ["web", "world"] web = [ "dep:leptos", "dep:leptos_axum", "dep:unavi-web-app" ] +world = [] diff --git a/server/README.md b/server/README.md index 65cb5adac..07634de84 100644 --- a/server/README.md +++ b/server/README.md @@ -1,46 +1,41 @@ # Server -A modular UNAVI home server. +A modular UNAVI server. ## Architecture -Home server functionality is divided into separate containers. -Each container can be enabled or disabled, allowing for flexibility in deployment. -Note that some containers rely on other containers. +Home server functionality is divided into separate features. +Each feature can be enabled or disabled, allowing for flexibility in deployment. +Note that some features rely on other features. For example, I may want to run a lightweight home server that only handles user identity, -and disable the other containers. -Or I may want to split up my service and run each container on a separate machine. +and disable the other features. +Or I may want to split up my service and run each feature on a separate machine.
-## Containers +## Features ### DB -The DB container runs a MySQL database. +MySQL database. ### IPFS -The IPFS container runs an IPFS Kubo node for file storage and retrieval. +IPFS Kubo node, used for file storage and retrieval. ### Identity -The identity container handles allows users to use the server as their home server. -It handles user authentication, and federates social interactions with other servers. - -### Router - -The router is the entrypoint into the service. -It recieves external requests and delegates them to other containers. +Allows users to use the server as their home server. +Handles user authentication, and federates social interactions with other servers. ### Web -The web container hosts a web client. +Hosts a web client. ### World -The world container handles world networking over WebSockets and WebRTC. -It is the multiplayer server that connects users in a world together. +Allows worlds to use the server as their world server. +Handles networking, connecting player's within a world together. diff --git a/server/src/main.rs b/server/src/main.rs index 784f9196c..df64cd723 100644 --- a/server/src/main.rs +++ b/server/src/main.rs @@ -5,18 +5,25 @@ use std::net::SocketAddr; #[cfg(feature = "web")] mod web; +#[cfg(feature = "world")] +mod world; #[tokio::main] async fn main() { println!("Features:"); let feat_web = cfg!(feature = "web"); println!("- web: {}", feat_web); + let feat_world = cfg!(feature = "world"); + println!("- world: {}", feat_world); let router = Router::new().route("/ping", get(ping)); #[cfg(feature = "web")] let router = router.merge(web::router().await); + #[cfg(feature = "world")] + let router = router.merge(world::router().await); + let addr = SocketAddr::from(([127, 0, 0, 1], 3000)); println!("Listening on {}", addr); diff --git a/server/src/world/mod.rs b/server/src/world/mod.rs new file mode 100644 index 000000000..9741911fc --- /dev/null +++ b/server/src/world/mod.rs @@ -0,0 +1,6 @@ +use axum::Router; + +pub async fn router() -> Router { + let router: Router = Router::new(); + router +}