Add WIP relays to database and api
This commit is contained in:
parent
4e3df272c3
commit
734f8b291c
14 changed files with 387 additions and 88 deletions
emgauwa-controller/src
|
@ -10,10 +10,12 @@ use tokio_tungstenite::tungstenite::Error;
|
|||
use emgauwa_lib::db;
|
||||
use emgauwa_lib::db::Controller;
|
||||
use emgauwa_lib::db::types::ControllerUid;
|
||||
use crate::relay_loop::run_relay_loop;
|
||||
use crate::settings::Settings;
|
||||
|
||||
mod settings;
|
||||
mod driver;
|
||||
mod relay_loop;
|
||||
|
||||
fn create_this_controller(conn: &mut PoolConnection<Sqlite>, settings: &Settings) -> Controller {
|
||||
futures::executor::block_on(async {
|
||||
|
@ -43,8 +45,9 @@ async fn main() {
|
|||
|
||||
let this_json = serde_json::to_string(&this).unwrap();
|
||||
|
||||
println!("{:?}", settings.relays);
|
||||
println!("{:?}", this);
|
||||
println!("{:?}", this_json);
|
||||
println!("{}", this_json);
|
||||
|
||||
let url = format!(
|
||||
"ws://{}:{}/api/v1/ws/controllers",
|
||||
|
@ -61,10 +64,12 @@ async fn main() {
|
|||
|
||||
write.send(Message::text(this_json)).await.unwrap();
|
||||
let ws_to_stdout = read.for_each(handle_message);
|
||||
let stdin_to_ws = stdin_rx.map(Ok).forward(write);
|
||||
|
||||
ws_to_stdout.await;
|
||||
//pin_mut!(stdin_to_ws, ws_to_stdout);
|
||||
//future::select(stdin_to_ws, ws_to_stdout).await;
|
||||
tokio::spawn(run_relay_loop(settings));
|
||||
|
||||
pin_mut!(stdin_to_ws, ws_to_stdout);
|
||||
future::select(stdin_to_ws, ws_to_stdout).await;
|
||||
}
|
||||
|
||||
// Our helper method which will read data from stdin and send it along the
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue