pub async fn perform_handshake<T: AsyncRead + AsyncWrite + Send + 'static>(
stream: T,
) -> ResultExamples found in repository?
examples/internal_server.rs (line 8)
7async fn handle_connection(_: SocketAddr, stream: TcpStream) {
8 match perform_handshake(stream).await {
9 Ok(mut ws_connection) => loop {
10 select! {
11 Some(result) = ws_connection.read.recv() => {
12 match result {
13 Ok(message) => {
14 if ws_connection.send_data(message).await.is_err() {
15 eprintln!("Failed to send message");
16 break;
17 }
18 }
19 Err(err) => {
20 eprintln!("Received error from the stream: {}", err);
21 break;
22 }
23 }
24 }
25 else => break
26 }
27 },
28 Err(err) => eprintln!("Error when performing handshake: {}", err),
29 }
30}