Created
January 31, 2018 19:25
-
-
Save ekse/ceee2fdbd673369ef14a327154f81538 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extern crate ws; | |
use ws::{WebSocket, Sender, Handler, Factory, Message}; | |
fn gimme_websocket() -> WebSocket<Factory<Handler = FnMut(Sender) -> (Fn(Message) -> ws::Result<()>)>> { | |
let f = |output: Sender| { | |
// The closure handler needs to take ownership of output | |
let handler = move |msg| { | |
println!("got '{}' ", msg); | |
}; | |
// We must return the handler | |
handler | |
}; | |
let ws = WebSocket::new(f); | |
ws | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment