From 96b87761d10dc238485590709bd563bea116b0a5 Mon Sep 17 00:00:00 2001 From: Nikolay Kim Date: Mon, 12 Feb 2018 23:13:06 -0800 Subject: [PATCH] update examples --- examples/diesel/src/main.rs | 2 +- examples/websocket-chat/src/client.rs | 4 ++-- examples/websocket-chat/src/main.rs | 12 ++++++------ examples/websocket-chat/src/server.rs | 6 +++--- examples/websocket-chat/src/session.rs | 12 ++++++------ examples/websocket/src/client.rs | 4 ++-- 6 files changed, 20 insertions(+), 20 deletions(-) diff --git a/examples/diesel/src/main.rs b/examples/diesel/src/main.rs index 4f61fa0b4..75c201558 100644 --- a/examples/diesel/src/main.rs +++ b/examples/diesel/src/main.rs @@ -38,7 +38,7 @@ struct State { fn index(req: HttpRequest) -> Box> { let name = &req.match_info()["name"]; - req.state().db.call(CreateUser{name: name.to_owned()}) + req.state().db.send(CreateUser{name: name.to_owned()}) .from_err() .and_then(|res| { match res { diff --git a/examples/websocket-chat/src/client.rs b/examples/websocket-chat/src/client.rs index d3b556b6f..4b69e6bf5 100644 --- a/examples/websocket-chat/src/client.rs +++ b/examples/websocket-chat/src/client.rs @@ -45,7 +45,7 @@ fn main() { return } - addr.send(ClientCommand(cmd)); + addr.do_send(ClientCommand(cmd)); } }); @@ -81,7 +81,7 @@ impl Actor for ChatClient { println!("Disconnected"); // Stop application on disconnect - Arbiter::system().send(actix::msgs::SystemExit(0)); + Arbiter::system().do_send(actix::msgs::SystemExit(0)); true } diff --git a/examples/websocket-chat/src/main.rs b/examples/websocket-chat/src/main.rs index 88e8590ef..4fefedc55 100644 --- a/examples/websocket-chat/src/main.rs +++ b/examples/websocket-chat/src/main.rs @@ -63,7 +63,7 @@ impl Actor for WsChatSession { // HttpContext::state() is instance of WsChatSessionState, state is shared across all // routes within application let addr: Addr = ctx.address(); - ctx.state().addr.call(server::Connect{addr: addr.subscriber()}) + ctx.state().addr.send(server::Connect{addr: addr.recipient()}) .into_actor(self) .then(|res, act, ctx| { match res { @@ -77,7 +77,7 @@ impl Actor for WsChatSession { fn stopping(&mut self, ctx: &mut Self::Context) -> bool { // notify chat server - ctx.state().addr.send(server::Disconnect{id: self.id}); + ctx.state().addr.do_send(server::Disconnect{id: self.id}); true } } @@ -109,7 +109,7 @@ impl Handler for WsChatSession { "/list" => { // Send ListRooms message to chat server and wait for response println!("List rooms"); - ctx.state().addr.call(server::ListRooms) + ctx.state().addr.send(server::ListRooms) .into_actor(self) .then(|res, _, ctx| { match res { @@ -129,7 +129,7 @@ impl Handler for WsChatSession { "/join" => { if v.len() == 2 { self.room = v[1].to_owned(); - ctx.state().addr.send( + ctx.state().addr.do_send( server::Join{id: self.id, name: self.room.clone()}); ctx.text("joined"); @@ -153,7 +153,7 @@ impl Handler for WsChatSession { m.to_owned() }; // send message to chat server - ctx.state().addr.send( + ctx.state().addr.do_send( server::Message{id: self.id, msg: msg, room: self.room.clone()}) @@ -178,7 +178,7 @@ fn main() { // Start tcp server in separate thread let srv = server.clone(); - Arbiter::new("tcp-server").send::( + Arbiter::new("tcp-server").do_send::( msgs::Execute::new(move || { session::TcpServer::new("127.0.0.1:12345", srv); Ok(()) diff --git a/examples/websocket-chat/src/server.rs b/examples/websocket-chat/src/server.rs index 6cae978f6..8b735b852 100644 --- a/examples/websocket-chat/src/server.rs +++ b/examples/websocket-chat/src/server.rs @@ -15,7 +15,7 @@ use session; #[derive(Message)] #[rtype(usize)] pub struct Connect { - pub addr: Subscriber, + pub addr: Recipient, } /// Session is disconnected @@ -54,7 +54,7 @@ pub struct Join { /// `ChatServer` manages chat rooms and responsible for coordinating chat session. /// implementation is super primitive pub struct ChatServer { - sessions: HashMap>, + sessions: HashMap>, rooms: HashMap>, rng: RefCell, } @@ -80,7 +80,7 @@ impl ChatServer { for id in sessions { if *id != skip_id { if let Some(addr) = self.sessions.get(id) { - let _ = addr.send(session::Message(message.to_owned())); + let _ = addr.do_send(session::Message(message.to_owned())); } } } diff --git a/examples/websocket-chat/src/session.rs b/examples/websocket-chat/src/session.rs index a5642db9f..a1a86bbbe 100644 --- a/examples/websocket-chat/src/session.rs +++ b/examples/websocket-chat/src/session.rs @@ -46,7 +46,7 @@ impl Actor for ChatSession { // future within context, but context waits until this future resolves // before processing any other events. let addr: Addr = ctx.address(); - self.addr.call(server::Connect{addr: addr.subscriber()}) + self.addr.send(server::Connect{addr: addr.recipient()}) .into_actor(self) .then(|res, act, ctx| { match res { @@ -60,7 +60,7 @@ impl Actor for ChatSession { fn stopping(&mut self, ctx: &mut Self::Context) -> bool { // notify chat server - self.addr.send(server::Disconnect{id: self.id}); + self.addr.do_send(server::Disconnect{id: self.id}); true } } @@ -76,7 +76,7 @@ impl StreamHandler for ChatSession { ChatRequest::List => { // Send ListRooms message to chat server and wait for response println!("List rooms"); - self.addr.call(server::ListRooms) + self.addr.send(server::ListRooms) .into_actor(self) .then(|res, act, ctx| { match res { @@ -93,13 +93,13 @@ impl StreamHandler for ChatSession { ChatRequest::Join(name) => { println!("Join to room: {}", name); self.room = name.clone(); - self.addr.send(server::Join{id: self.id, name: name.clone()}); + self.addr.do_send(server::Join{id: self.id, name: name.clone()}); self.framed.write(ChatResponse::Joined(name)); }, ChatRequest::Message(message) => { // send message to chat server println!("Peer message: {}", message); - self.addr.send( + self.addr.do_send( server::Message{id: self.id, msg: message, room: self.room.clone()}) @@ -141,7 +141,7 @@ impl ChatSession { println!("Client heartbeat failed, disconnecting!"); // notify chat server - act.addr.send(server::Disconnect{id: act.id}); + act.addr.do_send(server::Disconnect{id: act.id}); // stop actor ctx.stop(); diff --git a/examples/websocket/src/client.rs b/examples/websocket/src/client.rs index 38a7bd5eb..32b96873a 100644 --- a/examples/websocket/src/client.rs +++ b/examples/websocket/src/client.rs @@ -41,7 +41,7 @@ fn main() { println!("error"); return } - addr.send(ClientCommand(cmd)); + addr.do_send(ClientCommand(cmd)); } }); @@ -70,7 +70,7 @@ impl Actor for ChatClient { println!("Stopping"); // Stop application on disconnect - Arbiter::system().send(actix::msgs::SystemExit(0)); + Arbiter::system().do_send(actix::msgs::SystemExit(0)); true }