implemented notifications and messages

This commit is contained in:
mb 2022-08-22 15:54:36 +03:00
parent 28a3812812
commit 695ac6daa2
12 changed files with 1023 additions and 315 deletions

View file

@ -1,26 +1,26 @@
use telecomande::{Executor, SimpleExecutor};
use tokio::net::TcpListener;
#[tokio::main]
const ADDRESS: &'static str = "localhost:42069";
const DB_PATH: &'static str = "./db.test";
#[tokio::main]
async fn main() {
println!("[main/info] starting server ...");
let sessions = SimpleExecutor::new(SessionProc::default()).spawn();
println!("[main/info] spawned sessions");
let storage = SimpleExecutor::new(StorageProc::new("/tmp/db.test")).spawn();
let storage = SimpleExecutor::new(StorageProc::new(DB_PATH)).spawn();
println!("[main/info] spawned storage");
let gateway =
SimpleExecutor::new(GatewayProc::new(sessions.remote(), storage.remote())).spawn();
println!("[main/info] spawned gateway");
let listener = TcpListener::bind("localhost:8080").await.unwrap();
println!("[main/info] listening on 'localhost:8080' ...");
let listener = TcpListener::bind(ADDRESS).await.unwrap();
println!("[main/info] listening on '{ADDRESS}' ...");
let client_handler = sessions.remote();
loop {
let (stream, address) = listener.accept().await.unwrap();
println!("[main/info] new connection from '{address:?}'");
client_handler
.send(sessions::SessionCmd::AddSession(
stream,