From 631fe72a46588292beda8ed7f2ea2abc916281d2 Mon Sep 17 00:00:00 2001 From: Nikolay Kim Date: Sun, 4 Mar 2018 10:18:42 -0800 Subject: [PATCH] websockets text() is more generic --- src/ws/client.rs | 2 +- src/ws/context.rs | 2 +- tools/wsload/src/wsclient.rs | 24 ++++++++++++------------ 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/ws/client.rs b/src/ws/client.rs index 17c2e8320..c8fdec0ff 100644 --- a/src/ws/client.rs +++ b/src/ws/client.rs @@ -489,7 +489,7 @@ impl ClientWriter { /// Send text frame #[inline] - pub fn text>(&mut self, text: T) { + pub fn text>(&mut self, text: T) { self.write(Frame::message(text.into(), OpCode::Text, true, true)); } diff --git a/src/ws/context.rs b/src/ws/context.rs index 56320c895..4b0775f6a 100644 --- a/src/ws/context.rs +++ b/src/ws/context.rs @@ -132,7 +132,7 @@ impl WebsocketContext where A: Actor { /// Send text frame #[inline] - pub fn text>(&mut self, text: T) { + pub fn text>(&mut self, text: T) { self.write(Frame::message(text.into(), OpCode::Text, true, false)); } diff --git a/tools/wsload/src/wsclient.rs b/tools/wsload/src/wsclient.rs index e6438c634..2d8db7fb7 100644 --- a/tools/wsload/src/wsclient.rs +++ b/tools/wsload/src/wsclient.rs @@ -19,7 +19,7 @@ use futures::Future; use rand::{thread_rng, Rng}; use actix::prelude::*; -use actix_web::ws::{Message, WsClientError, WsClient, WsClientWriter}; +use actix_web::ws; fn main() { @@ -71,21 +71,21 @@ fn main() { let perf = perf_counters.clone(); let addr = Arbiter::new(format!("test {}", t)); - addr.send(actix::msgs::Execute::new(move || -> Result<(), ()> { + addr.do_send(actix::msgs::Execute::new(move || -> Result<(), ()> { let mut reps = report; for _ in 0..concurrency { let pl2 = pl.clone(); let perf2 = perf.clone(); Arbiter::handle().spawn( - WsClient::new(&ws).connect().unwrap() + ws::Client::new(&ws).connect() .map_err(|e| { println!("Error: {}", e); - Arbiter::system().send(actix::msgs::SystemExit(0)); + Arbiter::system().do_send(actix::msgs::SystemExit(0)); () }) .map(move |(reader, writer)| { - let addr: SyncAddress<_> = ChatClient::create(move |ctx| { + let addr: Addr = ChatClient::create(move |ctx| { ChatClient::add_stream(reader, ctx); ChatClient{conn: writer, payload: pl2, @@ -114,7 +114,7 @@ fn parse_u64_default(input: Option<&str>, default: u64) -> u64 { } struct ChatClient{ - conn: WsClientWriter, + conn: ws::ClientWriter, payload: Arc, ts: u64, bin: bool, @@ -133,9 +133,9 @@ impl Actor for ChatClient { } } - fn stopping(&mut self, _: &mut Context) -> bool { - Arbiter::system().send(actix::msgs::SystemExit(0)); - true + fn stopping(&mut self, _: &mut Context) -> Running { + Arbiter::system().do_send(actix::msgs::SystemExit(0)); + Running::Stop } } @@ -171,15 +171,15 @@ impl ChatClient { } /// Handle server websocket messages -impl StreamHandler for ChatClient { +impl StreamHandler for ChatClient { fn finished(&mut self, ctx: &mut Context) { ctx.stop() } - fn handle(&mut self, msg: Message, ctx: &mut Context) { + fn handle(&mut self, msg: ws::Message, ctx: &mut Context) { match msg { - Message::Text(txt) => { + ws::Message::Text(txt) => { if txt == self.payload.as_ref().as_str() { self.perf_counters.register_request(); self.perf_counters.register_latency(time::precise_time_ns() - self.ts);