Update to work on stable

pull/1/head
Danny Browning 5 years ago committed by Sebastian Dröge
parent 1764a42b19
commit 3ccd307be3
  1. 2
      Cargo.toml
  2. 6
      examples/autobahn-server.rs
  3. 6
      examples/server.rs
  4. 8
      tests/communication.rs
  5. 5
      tests/handshakes.rs

@ -19,7 +19,7 @@ stream = ["bytes"]
[dependencies]
log = "0.4"
futures = { version = "0.3", features = ["async-await"] }
futures = "0.3"
pin-project = "0.4"
[dependencies.tungstenite]

@ -25,12 +25,10 @@ async fn run() {
.expect("Not a valid address")
.next()
.expect("Not a socket address");
let socket = TcpListener::bind(&addr).await.unwrap();
let mut incoming = socket.incoming();
let listener = TcpListener::bind(&addr).await.unwrap();
info!("Listening on: {}", addr);
while let Some(stream) = incoming.next().await {
let stream = stream.expect("Failed to get stream");
while let Ok((stream, _)) = listener.accept().await {
let peer = stream
.peer_addr()
.expect("connected streams should have a peer address");

@ -92,12 +92,10 @@ async fn run() -> Result<(), Error> {
// Create the event loop and TCP listener we'll accept connections on.
let try_socket = TcpListener::bind(&addr).await;
let socket = try_socket.expect("Failed to bind");
let mut incoming = socket.incoming();
let listener = try_socket.expect("Failed to bind");
info!("Listening on: {}", addr);
while let Some(stream) = incoming.next().await {
let stream = stream.expect("Failed to accept stream");
while let Ok((stream, _)) = listener.accept().await {
task::spawn(accept_connection(stream));
}

@ -37,12 +37,10 @@ async fn communication() {
.next()
.expect("No address resolved");
let listener = TcpListener::bind(&address).await.unwrap();
let mut connections = listener.incoming();
info!("Server ready");
con_tx.send(()).unwrap();
info!("Waiting on next connection");
let connection = connections.next().await.expect("No connections to accept");
let connection = connection.expect("Failed to accept connection");
let (connection, _) = listener.accept().await.expect("No connections to accept");
let stream = accept_async(connection).await;
let stream = stream.expect("Failed to handshake with connection");
run_connection(stream, msg_tx).await;
@ -94,12 +92,10 @@ async fn split_communication() {
.next()
.expect("No address resolved");
let listener = TcpListener::bind(&address).await.unwrap();
let mut connections = listener.incoming();
info!("Server ready");
con_tx.send(()).unwrap();
info!("Waiting on next connection");
let connection = connections.next().await.expect("No connections to accept");
let connection = connection.expect("Failed to accept connection");
let (connection, _) = listener.accept().await.expect("No connections to accept");
let stream = accept_async(connection).await;
let stream = stream.expect("Failed to handshake with connection");
run_connection(stream, msg_tx).await;

@ -1,4 +1,3 @@
use futures::StreamExt;
use async_std::task;
use async_std::net::{TcpListener, TcpStream, ToSocketAddrs};
use async_tungstenite::{accept_async, client_async};
@ -15,10 +14,8 @@ async fn handshakes() {
.next()
.expect("No address resolved");
let listener = TcpListener::bind(&address).await.unwrap();
let mut connections = listener.incoming();
tx.send(()).unwrap();
while let Some(connection) = connections.next().await {
let connection = connection.expect("Failed to accept connection");
while let Ok((connection, _)) = listener.accept().await {
let stream = accept_async(connection).await;
stream.expect("Failed to handshake with connection");
}

Loading…
Cancel
Save