Skip to content

Commit

Permalink
Use SinkExt for autobahn-server
Browse files Browse the repository at this point in the history
  • Loading branch information
BillGoldenWater committed Dec 7, 2024
1 parent abe97c0 commit 2f7c1d6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions examples/autobahn-client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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?;
}
}
Expand Down
4 changes: 3 additions & 1 deletion examples/autobahn-server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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?;
}
}

Expand Down

0 comments on commit 2f7c1d6

Please sign in to comment.