Skip to content

Commit

Permalink
Prepare update to tungstenite 0.20
Browse files Browse the repository at this point in the history
  • Loading branch information
alexheretic authored and sdroege committed Jun 2, 2023
1 parent fa1977b commit 0099fa8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ futures-io = { version = "0.3", default-features = false, features = ["std"] }
pin-project-lite = "0.2"

[dependencies.tungstenite]
version = "0.19"
version = "0.20"
default-features = false

[dependencies.async-std]
Expand Down
12 changes: 6 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -334,11 +334,11 @@ where
match futures_util::ready!(self.with_context(Some((ContextWaker::Read, cx)), |s| {
#[cfg(feature = "verbose-logging")]
trace!(
"{}:{} Stream.with_context poll_next -> read_message()",
"{}:{} Stream.with_context poll_next -> read()",
file!(),
line!()
);
cvt(s.read_message())
cvt(s.read())
})) {
Ok(v) => Poll::Ready(Some(Ok(v))),
Err(e) => {
Expand Down Expand Up @@ -373,7 +373,7 @@ where
}

fn start_send(mut self: Pin<&mut Self>, item: Message) -> Result<(), Self::Error> {
match (*self).with_context(None, |s| s.write_message(item)) {
match (*self).with_context(None, |s| s.write(item)) {
Ok(()) => Ok(()),
Err(WsError::Io(err)) if err.kind() == std::io::ErrorKind::WouldBlock => {
// the message was accepted and queued
Expand All @@ -388,7 +388,7 @@ where
}

fn poll_flush(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
(*self).with_context(Some((ContextWaker::Write, cx)), |s| cvt(s.write_pending())).map(|r| {
(*self).with_context(Some((ContextWaker::Write, cx)), |s| cvt(s.flush())).map(|r| {
// WebSocket connection has just been closed. Flushing completed, not an error.
match r {
Err(WsError::ConnectionClosed) => Ok(()),
Expand All @@ -399,8 +399,8 @@ where

fn poll_close(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
let res = if self.closing {
// After queueing it, we call `write_pending` to drive the close handshake to completion.
(*self).with_context(Some((ContextWaker::Write, cx)), |s| s.write_pending())
// After queueing it, we call `flush` to drive the close handshake to completion.
(*self).with_context(Some((ContextWaker::Write, cx)), |s| s.flush())
} else {
(*self).with_context(Some((ContextWaker::Write, cx)), |s| s.close(None))
};
Expand Down

0 comments on commit 0099fa8

Please sign in to comment.