Add self-creation for controller
This commit is contained in:
parent
d193000aec
commit
4e3df272c3
10 changed files with 105 additions and 14 deletions
emgauwa-lib/src/handlers/v1/ws
|
@ -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)
|
||||
},
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue