From e7bab13e6d8c8c42fed3c8c5fe1abe5ea336b00f Mon Sep 17 00:00:00 2001 From: Zoldszemesostoros <42379455+Zoldszemesostoros@users.noreply.github.com> Date: Mon, 17 Aug 2020 11:47:00 +0200 Subject: [PATCH] make echo server compile The original code failed to compile with "expected item after doc comment" error message --- README.md | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index f5a7ff9..a0351db 100644 --- a/README.md +++ b/README.md @@ -8,19 +8,21 @@ use std::thread::spawn; use tungstenite::server::accept; /// A WebSocket echo server -let server = TcpListener::bind("127.0.0.1:9001").unwrap(); -for stream in server.incoming() { - spawn (move || { - let mut websocket = accept(stream.unwrap()).unwrap(); - loop { - let msg = websocket.read_message().unwrap(); - - // We do not want to send back ping/pong messages. - if msg.is_binary() || msg.is_text() { - websocket.write_message(msg).unwrap(); +fn main () { + let server = TcpListener::bind("127.0.0.1:9001").unwrap(); + for stream in server.incoming() { + spawn (move || { + let mut websocket = accept(stream.unwrap()).unwrap(); + loop { + let msg = websocket.read_message().unwrap(); + + // We do not want to send back ping/pong messages. + if msg.is_binary() || msg.is_text() { + websocket.write_message(msg).unwrap(); + } } - } - }); + }); + } } ```