aboutsummaryrefslogtreecommitdiff
path: root/crates/whirl_server/src/lib.rs
diff options
context:
space:
mode:
authorFuwn <[email protected]>2021-05-26 23:34:03 -0700
committerFuwn <[email protected]>2021-05-26 23:34:03 -0700
commitfca71ccccab25645de00406bd88d6132941f35dc (patch)
tree416ad62d129d5a27218fed3d3662b9cda28ac13d /crates/whirl_server/src/lib.rs
parentdocs(crates): clarify that whirl_db is unimplemented (diff)
downloadwhirl-fca71ccccab25645de00406bd88d6132941f35dc.tar.xz
whirl-fca71ccccab25645de00406bd88d6132941f35dc.zip
refactor(global): move thread creation to respective crates
Diffstat (limited to 'crates/whirl_server/src/lib.rs')
-rw-r--r--crates/whirl_server/src/lib.rs23
1 files changed, 22 insertions, 1 deletions
diff --git a/crates/whirl_server/src/lib.rs b/crates/whirl_server/src/lib.rs
index a5efc24..1a00c61 100644
--- a/crates/whirl_server/src/lib.rs
+++ b/crates/whirl_server/src/lib.rs
@@ -33,8 +33,14 @@ use tokio::{
net::{TcpListener, TcpStream},
sync::Mutex,
};
+use whirl_config::Config;
-use crate::interaction::shared::Shared;
+use crate::{
+ distributor::Distributor,
+ hub::Hub,
+ interaction::shared::Shared,
+ ServerType::{AutoServer, RoomServer},
+};
/// The type of server the `listen` method of the `Server` trait will
/// implemented for.
@@ -92,3 +98,18 @@ pub trait Server {
count: usize,
) -> Result<(), Box<dyn Error>>;
}
+
+pub fn make() -> Vec<tokio::task::JoinHandle<()>> {
+ vec![
+ tokio::spawn(async move {
+ let _ = Distributor::listen(
+ &*format!("0.0.0.0:{}", Config::get().distributor.port),
+ AutoServer,
+ )
+ .await;
+ }),
+ tokio::spawn(async move {
+ let _ = Hub::listen(&*format!("0.0.0.0:{}", Config::get().hub.port), RoomServer).await;
+ }),
+ ]
+}