use hippotat::prelude::*;
-mod sclient;
+mod suser;
+mod slocal;
mod sweb;
pub use sweb::{WebRequest, WebResponse};
-pub use sclient::Client;
+pub use suser::User;
#[derive(StructOpt,Debug)]
pub struct Opts {
#[derive(Debug)]
pub struct Global {
config: config::InstanceConfigGlobal,
- all_clients: HashMap<ClientName, Client>,
+ local_rx: mpsc::Sender<RoutedPacket>,
+ all_clients: HashMap<ClientName, User>,
}
pub type RoutedPacket = Box<[u8]>; // not MIME data
String,
)> = vec![];
- let (global, ipif) = config::startup(
+ let global = config::startup(
"hippotatd", LinkEnd::Server,
&opts.config, &opts.log, |ics|
{
client_handles_send,
).map(|(ic, (web_send, route_send))| {
(ic.link.client,
- Client {
+ User {
ic: ic.clone(),
web: web_send,
route: route_send,
})
}).collect();
+ let (local_rx_send, local_tx_recv) = mpsc::channel(
+ 50 // xxx configurable?
+ );
+
let global = Arc::new(Global {
config: global_config,
+ local_rx: local_rx_send,
all_clients,
});
let global_ = global.clone();
let ic_ = ic.clone();
tasks.push((tokio::spawn(async move {
- sclient::run(global_, ic_, web_recv, route_recv)
+ suser::run(global_, ic_, web_recv, route_recv)
.await.void_unwrap_err()
}), format!("client {}", &ic)));
}
});
tasks.push((task, format!("http server {}", addr)));
}
-
- Ok((global, ipif))
+
+ let global_ = global.clone();
+ let ipif = tokio::task::spawn(async move {
+ slocal::run(global_, local_tx_recv, ipif).await
+ .void_unwrap_err()
+ });
+ tasks.push((ipif, format!("ipif")));
+
+ Ok(global)
});
let died = future::select_all(
).await;
error!("xxx {:?}", &died);
- ipif.quitting(None).await;
-
dbg!(global);
}