From 00ac624659450e47e8aa17871dc1e43679765d62 Mon Sep 17 00:00:00 2001 From: anthonyjchriste Date: Mon, 24 Jun 2019 08:57:44 -1000 Subject: [PATCH] Revert to previous not-formatted code. --- actix-web-actors/src/ws.rs | 50 ++++++-------------------------------- 1 file changed, 8 insertions(+), 42 deletions(-) diff --git a/actix-web-actors/src/ws.rs b/actix-web-actors/src/ws.rs index e9c9b0436..5078b7832 100644 --- a/actix-web-actors/src/ws.rs +++ b/actix-web-actors/src/ws.rs @@ -35,16 +35,6 @@ pub fn start(actor: A, req: &HttpRequest, stream: T) -> Result(actor: A, req: &HttpRequest, stream: T, limit: usize) -> Result - where - A: Actor> + StreamHandler, - T: Stream + 'static, -{ - let mut res = handshake(req)?; - Ok(res.streaming(WebsocketContext::create_with_limit(actor, stream, limit))) -} - /// Prepare `WebSocket` handshake response. /// /// This function returns handshake `HttpResponse`, ready to send to peer. @@ -181,25 +171,15 @@ impl WebsocketContext where A: StreamHandler, S: Stream + 'static, - { - WebsocketContext::create_with_limit(actor, stream, 65_536) - } - - #[inline] - /// Create a new Websocket context from a request, an actor, and a limit - pub fn create_with_limit(actor: A, stream: S, limit: usize) -> impl Stream - where - A: StreamHandler, - S: Stream + 'static, { let mb = Mailbox::default(); let mut ctx = WebsocketContext { inner: ContextParts::new(mb.sender_producer()), messages: VecDeque::new(), }; - ctx.add_stream(WsStream::new(stream, limit)); + ctx.add_stream(WsStream::new(stream)); - WebsocketContextFut::new(ctx, actor, mb, limit) + WebsocketContextFut::new(ctx, actor, mb) } /// Create a new Websocket context @@ -211,31 +191,17 @@ impl WebsocketContext F: FnOnce(&mut Self) -> A + 'static, A: StreamHandler, S: Stream + 'static, - { - WebsocketContext::with_factory_codec(stream, f, 65_536) - } - - /// Create a new Websocket context with a limit - pub fn with_factory_codec( - stream: S, - f: F, - limit: usize, - ) -> impl Stream - where - F: FnOnce(&mut Self) -> A + 'static, - A: StreamHandler, - S: Stream + 'static, { let mb = Mailbox::default(); let mut ctx = WebsocketContext { inner: ContextParts::new(mb.sender_producer()), messages: VecDeque::new(), }; - ctx.add_stream(WsStream::new(stream, limit)); + ctx.add_stream(WsStream::new(stream)); let act = f(&mut ctx); - WebsocketContextFut::new(ctx, act, mb, limit) + WebsocketContextFut::new(ctx, act, mb) } } @@ -322,11 +288,11 @@ impl WebsocketContextFut where A: Actor>, { - fn new(ctx: WebsocketContext, act: A, mailbox: Mailbox, limit: usize) -> Self { + fn new(ctx: WebsocketContext, act: A, mailbox: Mailbox) -> Self { let fut = ContextFut::new(ctx, act, mailbox); WebsocketContextFut { fut, - encoder: Codec::new().max_size(limit), + encoder: Codec::new(), buf: BytesMut::new(), closed: false, } @@ -387,10 +353,10 @@ impl WsStream where S: Stream, { - fn new(stream: S, limit: usize) -> Self { + fn new(stream: S) -> Self { Self { stream, - decoder: Codec::new().max_size(limit), + decoder: Codec::new(), buf: BytesMut::new(), closed: false, }