From 2f7c1d61f273515cab7570bad56019391f4ea60e Mon Sep 17 00:00:00 2001 From: Golden_Water Date: Sat, 7 Dec 2024 19:09:30 +0800 Subject: [PATCH] Use SinkExt for autobahn-server --- examples/autobahn-client.rs | 1 + examples/autobahn-server.rs | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/examples/autobahn-client.rs b/examples/autobahn-client.rs index 3c49b06..389caa7 100644 --- a/examples/autobahn-client.rs +++ b/examples/autobahn-client.rs @@ -32,6 +32,7 @@ async fn run_test(case: u32) -> Result<()> { while let Some(msg) = ws_stream.next().await { let msg = msg?; if msg.is_text() || msg.is_binary() { + // for Sink of futures 0.3, see autobahn-server example ws_stream.send(msg).await?; } } diff --git a/examples/autobahn-server.rs b/examples/autobahn-server.rs index 3f570e8..4f9c965 100644 --- a/examples/autobahn-server.rs +++ b/examples/autobahn-server.rs @@ -23,7 +23,9 @@ async fn handle_connection(peer: SocketAddr, stream: TcpStream) -> Result<()> { while let Some(msg) = ws_stream.next().await { let msg = msg?; if msg.is_text() || msg.is_binary() { - ws_stream.send(msg).await?; + // here we explicitly using futures 0.3's Sink implementation for send message + // for WebSocketStream::send, see autobahn-client example + futures::SinkExt::send(&mut ws_stream, msg).await?; } }