Fixed the bug that can accept subscription requests during the initialization of WebSocket.
@@ -93,6 +93,7 @@ where
fn poll_next(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Option<Self::Item>> {
let mut this = self.project();
+ if this.init_fut.is_none() {
while let Poll::Ready(message) = Pin::new(&mut this.stream).poll_next(cx) {
let message = match message {
Some(message) => message,
@@ -117,6 +118,7 @@ where
*this.init_fut = Some(Box::pin(async move {
data_initializer(payload.unwrap_or_default()).await
}));
+ break;
}
}
ClientMessage::Start {
@@ -144,6 +146,7 @@ where
ClientMessage::ConnectionTerminate => return Poll::Ready(None),
}
}
+ }
if let Some(init_fut) = this.init_fut {
if let Poll::Ready(res) = init_fut.poll_unpin(cx) {
