From 5482d64df51152e32642a97a25fb79edf1c36f49 Mon Sep 17 00:00:00 2001 From: kingxsp Date: Wed, 11 Jul 2018 10:05:43 +0800 Subject: [PATCH] Customize websocket max size --- src/ws/mod.rs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/ws/mod.rs b/src/ws/mod.rs index 05099971e..4fb1eecaa 100644 --- a/src/ws/mod.rs +++ b/src/ws/mod.rs @@ -171,18 +171,28 @@ pub enum Message { } /// Do websocket handshake and start actor -pub fn start(req: &HttpRequest, actor: A) -> Result +#[inline] +pub fn create(req: &HttpRequest, actor: A, max_size: usize) -> Result where A: Actor> + StreamHandler, S: 'static, { let mut resp = handshake(req)?; - let stream = WsStream::new(req.payload()); + let stream = WsStream::new(req.payload()).max_size(max_size); let body = WebsocketContext::create(req.clone(), actor, stream); Ok(resp.body(body)) } +/// Do websocket handshake and start actor +pub fn start(req: &HttpRequest, actor: A) -> Result +where + A: Actor> + StreamHandler, + S: 'static, +{ + create(req, actor, 65_536) +} + /// Prepare `WebSocket` handshake response. /// /// This function returns handshake `HttpResponse`, ready to send to peer.