aboutsummaryrefslogtreecommitdiff
path: root/src/subs.rs
blob: 5e0d7699759cbb583bab6f6580829e075522e419 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// Copyleft (ɔ) 2021-2021 The Whirlsplash Collective
// SPDX-License-Identifier: GPL-3.0-only

use crate::{
  api::Api,
  config::Config,
  prompt::Prompt,
  server::{
    distributor::Distributor,
    hub::Hub,
    server::{
      Server,
      ServerType::{AutoServer, RoomServer},
    },
  },
};

pub async fn run() -> ! {
  let _threads = vec![
    tokio::spawn(async move {
      let _ = Distributor::listen(
        &*format!("0.0.0.0:{}", Config::get().unwrap().distributor.port),
        AutoServer,
      )
      .await;
    }),
    tokio::spawn(async move {
      let _ = Hub::listen(
        &*format!("0.0.0.0:{}", Config::get().unwrap().hub.port),
        RoomServer,
      )
      .await;
    }),
    tokio::spawn(async move {
      let _ = Api::listen();
    }),
  ];

  std::thread::sleep(std::time::Duration::from_secs(2));
  loop {
    // TODO: Find a way to keep this persistent on the bottom row.
    Prompt::handle();
  }
}