Add WIP websocket to controller and refactor settings

This commit is contained in:
Tobias Reisinger 2023-11-23 16:00:24 +01:00
parent 452454f9e8
commit 32c75ad73a
Signed by: serguzim
GPG key ID: 13AD60C237A28DFE
11 changed files with 128 additions and 37 deletions
emgauwa-lib/src/handlers/v1/ws

View file

@ -25,6 +25,7 @@ impl StreamHandler<Result<Message, ProtocolError>> for ControllerWs {
fn handle(&mut self, msg: Result<Message, ProtocolError>, ctx: &mut Self::Context) {
let schedules = futures::executor::block_on(get_schedules(&mut self.pool)).unwrap();
let schedules_json = serde_json::to_string(&schedules).unwrap();
println!("{:?}", msg);
match msg {
Ok(Message::Ping(msg)) => ctx.pong(&msg),
Ok(Message::Text(_text)) => ctx.text(schedules_json),