Fixed the bug that can accept subscription requests during the initialization of WebSocket.

This commit is contained in:
Sunli 2021-02-06 09:24:00 +08:00
parent 244aa37738
commit d193a138e3

View File

@ -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) {