Add ControllerWsAction
This commit is contained in:
parent
cb47dcda5c
commit
3b596de06f
10 changed files with 134 additions and 34 deletions
emgauwa-controller/src
|
@ -3,6 +3,7 @@ use std::str;
|
|||
use crate::relay_loop::run_relay_loop;
|
||||
use crate::settings::Settings;
|
||||
use emgauwa_lib::db::{DbController, DbRelay};
|
||||
use emgauwa_lib::handlers::v1::ws::controllers::ControllerWsAction;
|
||||
use emgauwa_lib::models::convert_db_list;
|
||||
use emgauwa_lib::types::ControllerUid;
|
||||
use emgauwa_lib::{db, models};
|
||||
|
@ -96,10 +97,6 @@ async fn main() {
|
|||
relays,
|
||||
};
|
||||
|
||||
let this_json = serde_json::to_string(&this).unwrap();
|
||||
|
||||
println!("{}", this_json);
|
||||
|
||||
let url = format!(
|
||||
"ws://{}:{}/api/v1/ws/controllers",
|
||||
settings.core.host, settings.core.port
|
||||
|
@ -112,7 +109,11 @@ async fn main() {
|
|||
|
||||
let (mut write, read) = ws_stream.split();
|
||||
|
||||
write.send(Message::text(this_json)).await.unwrap();
|
||||
let ws_action = ControllerWsAction::Register(this);
|
||||
println!("Sending action: {:?}", ws_action);
|
||||
let ws_action_json = serde_json::to_string(&ws_action).unwrap();
|
||||
println!("Sending json: {}", ws_action_json);
|
||||
write.send(Message::text(ws_action_json)).await.unwrap();
|
||||
let ws_to_stdout = read.for_each(handle_message);
|
||||
let stdin_to_ws = stdin_rx.map(Ok).forward(write);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue