diff --git a/actix-web-actors/src/ws.rs b/actix-web-actors/src/ws.rs index 60942c6c6..999ddbda8 100644 --- a/actix-web-actors/src/ws.rs +++ b/actix-web-actors/src/ws.rs @@ -40,6 +40,43 @@ where Ok(res.streaming(WebsocketContext::create(actor, stream))) } +/// Perform WebSocket handshake and start actor with the given frame size. +pub fn start_with_frame_size( + actor: A, + req: &HttpRequest, + stream: T, + frame_size: usize, +) -> Result +where + A: Actor> + + StreamHandler>, + T: Stream> + 'static, +{ + let mut res = handshake(req)?; + Ok(res.streaming(WebsocketContext::with_codec( + actor, + stream, + Codec::new().max_size(frame_size), + ))) +} + +/// Perform WebSocket handshake and start actor with the given +/// `actix_http::ws::Codec`. +pub fn start_with_codec( + actor: A, + req: &HttpRequest, + stream: T, + codec: Codec, +) -> Result +where + A: Actor> + + StreamHandler>, + T: Stream> + 'static, +{ + let mut res = handshake(req)?; + Ok(res.streaming(WebsocketContext::with_codec(actor, stream, codec))) +} + /// Perform WebSocket handshake and start actor. /// /// `req` is an HTTP Request that should be requesting a websocket protocol