Add self-creation for controller

This commit is contained in:
Tobias Reisinger 2023-11-25 00:39:44 +01:00
parent d193000aec
commit 4e3df272c3
Signed by: serguzim
GPG key ID: 13AD60C237A28DFE
10 changed files with 105 additions and 14 deletions
emgauwa-lib/src/handlers/v1/ws

View file

@ -25,10 +25,12 @@ 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),
Ok(Message::Text(text)) => {
println!("Got text: {}", text.to_string());
ctx.text(schedules_json)
},
_ => {}
}
}