From 94dc0142c6499603991982f4af56bb7148d671b0 Mon Sep 17 00:00:00 2001 From: "Bryan A. Jones" Date: Wed, 22 May 2024 19:16:03 -0500 Subject: [PATCH] feat(ws): allow setting max frame size. --- actix-ws/CHANGELOG.md | 1 + actix-ws/src/fut.rs | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/actix-ws/CHANGELOG.md b/actix-ws/CHANGELOG.md index 97e4ccf46..9995b36df 100644 --- a/actix-ws/CHANGELOG.md +++ b/actix-ws/CHANGELOG.md @@ -2,6 +2,7 @@ ## Unreleased +- Allow changing the max frame size, using the newly-added `MessageStream::max_size` method. - Remove type parameters from `Session::{text, binary}()` methods, replacing with equivalent `impl Trait` parameters. - `Session::text()` now receives an `impl Into`, making broadcasting text messages more efficient. - Allow sending continuations via `Session::continuation()` diff --git a/actix-ws/src/fut.rs b/actix-ws/src/fut.rs index a025a429b..29409176d 100644 --- a/actix-ws/src/fut.rs +++ b/actix-ws/src/fut.rs @@ -76,6 +76,12 @@ impl MessageStream { pub async fn recv(&mut self) -> Option> { poll_fn(|cx| Pin::new(&mut *self).poll_next(cx)).await } + + /// Set max frame size. See `actix-http::ws::Codec::max_size`. + pub fn max_size(mut self, size: usize) -> Self { + self.codec = self.codec.max_size(size); + self + } } impl Stream for StreamingBody {