some optimizations and muxprotocolextensionstream for stream id 0

This commit is contained in:
Toshit Chawda 2024-04-27 17:36:06 -07:00
parent 3b8dedeba2
commit b3f35b232f
No known key found for this signature in database
GPG key ID: 91480ED99E2B3D9D
7 changed files with 237 additions and 170 deletions

View file

@ -1,10 +1,9 @@
use crate::*;
use std::{
pin::Pin,
sync::atomic::{AtomicBool, Ordering},
task::{Context, Poll},
ops::Deref, pin::Pin, sync::atomic::{AtomicBool, Ordering}, task::{Context, Poll}
};
use bytes::BytesMut;
use event_listener::Event;
use futures_util::{FutureExt, Stream};
use hyper::body::Body;
@ -207,7 +206,7 @@ impl WebSocketRead for WebSocketReader {
_ = self.close_event.listen().fuse() => Some(Closed),
};
match res.ok_or(WispError::WsImplSocketClosed)? {
Message(bin) => Ok(Frame::binary(bin.into())),
Message(bin) => Ok(Frame::binary(BytesMut::from(bin.deref()))),
Error => Err(WebSocketError::Unknown.into()),
Closed => Err(WispError::WsImplSocketClosed),
}