1
0
Fork 0
mirror of https://github.com/actix/actix-web.git synced 2025-01-02 21:38:46 +00:00

update example

This commit is contained in:
Nikolay Kim 2018-02-09 22:46:34 -08:00
parent 0c98775b51
commit 2d049e4a9f
3 changed files with 5 additions and 5 deletions

View file

@ -87,7 +87,7 @@ impl Handler<session::Message> for WsChatSession {
type Result = (); type Result = ();
fn handle(&mut self, msg: session::Message, ctx: &mut Self::Context) { fn handle(&mut self, msg: session::Message, ctx: &mut Self::Context) {
ctx.text(&msg.0); ctx.text(msg.0);
} }
} }
@ -113,7 +113,7 @@ impl Handler<ws::Message> for WsChatSession {
match res { match res {
Ok(Ok(rooms)) => { Ok(Ok(rooms)) => {
for room in rooms { for room in rooms {
ctx.text(&room); ctx.text(room);
} }
}, },
_ => println!("Something is wrong"), _ => println!("Something is wrong"),
@ -142,7 +142,7 @@ impl Handler<ws::Message> for WsChatSession {
ctx.text("!!! name is required"); ctx.text("!!! name is required");
} }
}, },
_ => ctx.text(&format!("!!! unknown command: {:?}", m)), _ => ctx.text(format!("!!! unknown command: {:?}", m)),
} }
} else { } else {
let msg = if let Some(ref name) = self.name { let msg = if let Some(ref name) = self.name {

View file

@ -33,7 +33,7 @@ impl Handler<ws::Message> for MyWebSocket {
println!("WS: {:?}", msg); println!("WS: {:?}", msg);
match msg { match msg {
ws::Message::Ping(msg) => ctx.pong(&msg), ws::Message::Ping(msg) => ctx.pong(&msg),
ws::Message::Text(text) => ctx.text(&text), ws::Message::Text(text) => ctx.text(text),
ws::Message::Binary(bin) => ctx.binary(bin), ws::Message::Binary(bin) => ctx.binary(bin),
ws::Message::Closed | ws::Message::Error => { ws::Message::Closed | ws::Message::Error => {
ctx.stop(); ctx.stop();

View file

@ -28,7 +28,7 @@ impl Handler<ws::Message> for Ws {
fn handle(&mut self, msg: ws::Message, ctx: &mut Self::Context) { fn handle(&mut self, msg: ws::Message, ctx: &mut Self::Context) {
match msg { match msg {
ws::Message::Ping(msg) => ctx.pong(&msg), ws::Message::Ping(msg) => ctx.pong(&msg),
ws::Message::Text(text) => ctx.text(&text), ws::Message::Text(text) => ctx.text(text),
ws::Message::Binary(bin) => ctx.binary(bin), ws::Message::Binary(bin) => ctx.binary(bin),
_ => (), _ => (),
} }