You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
tungstenite-rs/examples/client.rs

21 lines
523 B

extern crate tungstenite;
extern crate url;
extern crate env_logger;
use url::Url;
use tungstenite::{Message, connect};
fn main() {
env_logger::init().unwrap();
let (mut socket, _) = connect(Url::parse("ws://localhost:3012/socket").unwrap())
.expect("Can't connect");
socket.write_message(Message::Text("Hello WebSocket".into())).unwrap();
loop {
let msg = socket.read_message().expect("Error reading message");
println!("Received: {}", msg);
}
// socket.close(None);
}