send payload everywhere

This commit is contained in:
Toshit Chawda 2024-11-27 20:20:31 -08:00
parent f7be65ae74
commit 5b3fc56b38
No known key found for this signature in database
GPG key ID: 91480ED99E2B3D9D
5 changed files with 29 additions and 14 deletions

View file

@ -9,7 +9,7 @@ use crate::{
AtomicCloseReason, ClosePacket, CloseReason, ConnectPacket, MuxStream, Packet, PacketType,
Role, StreamType, WispError,
};
use bytes::{Bytes, BytesMut};
use bytes::BytesMut;
use event_listener::Event;
use flume as mpsc;
use futures::{channel::oneshot, select, stream::unfold, FutureExt, StreamExt};
@ -31,7 +31,7 @@ pub(crate) enum WsEvent<W: WebSocketWrite + 'static> {
}
struct MuxMapValue {
stream: mpsc::Sender<Bytes>,
stream: mpsc::Sender<Payload<'static>>,
stream_type: StreamType,
should_flow_control: bool,
@ -414,7 +414,7 @@ impl<R: WebSocketRead + 'static, W: WebSocketWrite + 'static> MuxInner<R, W> {
data.extend_from_slice(&extra_frame.payload);
}
}
let _ = stream.stream.try_send(data.freeze());
let _ = stream.stream.try_send(Payload::Bytes(data));
if self.role == Role::Server && stream.should_flow_control {
stream.flow_control.store(
stream