Skip to content

Instantly share code, notes, and snippets.

@saethlin
Created January 30, 2018 20:27
Show Gist options
  • Save saethlin/b10c0017c69aed2743fc045d92487faf to your computer and use it in GitHub Desktop.
Save saethlin/b10c0017c69aed2743fc045d92487faf to your computer and use it in GitHub Desktop.
rustfmtpls
let runner = ClientBuilder::new(&url)
.unwrap()
.add_protocol("rust-websocket")
.async_connect_secure(None, &core.handle())
.and_then(|(duplex, _)| {
let (sink, stream) = duplex.split();
stream.filter_map(|message| {
match message {
OwnedMessage::Text(t) => {
if let Ok(Standard(slackmessage)) = serde_json::from_str::<slack_api::Message>(&t) {
if let Some(omnimessage) = thread_handler.to_omni(slackmessage) {
thread_sender
.send(Event::Message(omnimessage))
.expect("Sender died");
None
} else {None}
}
}
OwnedMessage::Close(e) => Some(OwnedMessage::Close(e)),
OwnedMessage::Ping(d) => Some(OwnedMessage::Pong(d)),
_ => None,
}
})
//.select(stdin_ch.map_err(|_| WebSocketError::NoDataAvailable))
.forward(sink)
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment