Transforming socket.read_message() to str
badonyt opened this issue · 1 comments
badonyt commented
hey i have this code
use tungstenite::{connect};
use url::Url;
use std::process::Command;
fn main() {
env_logger::init();
let (mut socket, response) =
connect(Url::parse("ws://localhost:8080/").unwrap()).expect("Can't connect");
println!("Connected to the server");
println!("Response HTTP code: {}", response.status());
println!("Response contains the following headers:");
for (ref header, _value) in response.headers() {
println!("* {}", header);
}
//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);
}
how can i transform socket.read_message to str
badonyt commented
Figured it out