diff --git a/src/sockets/ws.rs b/src/sockets/ws.rs index ee99ced4b6..f4a08b4ceb 100644 --- a/src/sockets/ws.rs +++ b/src/sockets/ws.rs @@ -7,7 +7,7 @@ struct Server { impl Handler for Server { fn on_message(&mut self, msg: Message) -> Result<()> { - foomp(); + foomp(msg.clone()); // Echo the message back self.out.send(msg) } @@ -16,7 +16,9 @@ impl Handler for Server { match code { CloseCode::Normal => println!("The client is done with the connection."), CloseCode::Away => println!("The client is leaving the site."), - _ => println!("The client encountered an error: {}", reason), + _ => { + println!("The client encountered an error: {}", reason); + } } } } @@ -25,6 +27,8 @@ pub fn start(socket_address: SocketAddr) { listen(socket_address, |out| Server { out: out }).unwrap() } -fn foomp() { - println!("FOOOOOOOOOOOOOOOOOOOOOOOOMMMMMMMMMMMMPPPPPPPPPPPPPPPPP"); +// Proves we can call Rust methods from the websocket listener. Re-route it to wherever JS puts +// the `send_message` functionality. +fn foomp(msg: Message) { + println!("Foomp!: {:?}", msg); }