Skip to content

Commit e4927bf

Browse files
committed
feat: frame splitting
1 parent 7fc8dbd commit e4927bf

File tree

3 files changed

+14
-9
lines changed

3 files changed

+14
-9
lines changed

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ macros = { path = "./macros" }
3030
nb = "1.1.0"
3131
embassy-futures = "0.1.1"
3232
embassy-sync = "0.6.2"
33-
ws-framer = { version = "=0.2.2", features = ["alloc"] }
33+
ws-framer = { version = "0.3.0", default-features = false, features = ["alloc", "http", "getrandom02"] }
3434
embedded-hal-async = "1.0.0"
3535
portable-atomic = { version = "1.11.0", default-features = false }
3636
critical-section = "1.2.0"

src/ws.rs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -234,13 +234,18 @@ async fn ws_rw(
234234
let n = match embassy_futures::select::select(read_fut, write_fut).await {
235235
embassy_futures::select::Either::First(read_res) => read_res,
236236
embassy_futures::select::Either::Second(write_frame) => {
237-
if write_frame.into_ref().data().len() > WS_BUF_SIZE {
238-
log::error!("Skipping writing frame! Frame is too big! (Maybe split it?)");
239-
continue;
240-
}
237+
let mut offset = 0;
238+
let frame_ref = write_frame.into_ref();
239+
240+
loop {
241+
let (data, finish) = framer_tx.partial_frame(&frame_ref, &mut offset);
242+
socket.write_all(data).await.map_err(|_| ())?;
243+
if !finish {
244+
break;
245+
}
241246

242-
let data = framer_tx.frame(write_frame.into_ref());
243-
socket.write_all(data).await.map_err(|_| ())?;
247+
log::warn!("Frame splitted!");
248+
}
244249

245250
continue;
246251
}

0 commit comments

Comments
 (0)