Instantly share code, notes, and snippets.

Embed
What would you like to do?
Code shared from the Rust Playground
extern crate ws;
use ws::{connect, CloseCode};
fn main() {
connect("ws://127.0.0.1:3012", |out| {
for i in 0..501 {
let strs = vec!["Hello Websocket ".to_string(), i.to_string()];
let outstr = strs.join("");
out.send(outstr).unwrap()
}
move |msg| {
println!("Got message: {}", msg);
out.close(CloseCode::Normal)
}
})
.unwrap()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment