|
|
@ -8,12 +8,12 @@ Lightweight stream-based WebSocket implementation for [Rust](http://www.rust-lan |
|
|
|
let server = TcpListener::bind("127.0.0.1:9001").unwrap(); |
|
|
|
let server = TcpListener::bind("127.0.0.1:9001").unwrap(); |
|
|
|
for stream in server.incoming() { |
|
|
|
for stream in server.incoming() { |
|
|
|
spawn (move || { |
|
|
|
spawn (move || { |
|
|
|
let mut websocket = accept(stream.unwrap()); |
|
|
|
let mut websocket = accept(stream.unwrap()).unwrap(); |
|
|
|
loop { |
|
|
|
loop { |
|
|
|
let msg = websocket.read_message().unwrap(); |
|
|
|
let msg = websocket.read_message().unwrap(); |
|
|
|
websocket.write_message(msg).unwrap(); |
|
|
|
websocket.write_message(msg).unwrap(); |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
``` |
|
|
|
``` |
|
|
|
|
|
|
|
|
|
|
|