aboutsummaryrefslogtreecommitdiff
path: root/crates/whirl_server/src/lib.rs
diff options
context:
space:
mode:
authorFuwn <[email protected]>2021-05-26 23:34:03 +0000
committerFuwn <[email protected]>2021-05-26 23:34:03 +0000
commitc4df3731e3f3e28f7129930f83b34f4a4aadf614 (patch)
tree02e4b42e05347f76ecf55a0025649a745385b7c8 /crates/whirl_server/src/lib.rs
parentdocs(crates): clarify that whirl_db is unimplemented (diff)
downloadwhirl-c4df3731e3f3e28f7129930f83b34f4a4aadf614.tar.xz
whirl-c4df3731e3f3e28f7129930f83b34f4a4aadf614.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;
+ }),
+ ]
+}