Removing websocket changes as they don't architecturally work and thus require too many workarounds

A better architecture must be implemented to have good websocket support
This commit is contained in:
shockrah committed 2021-04-10 17:09:25 -07:00
1 parent 102c3b2a10
commit 3708d2cd08
2 files changed
+1 -25

No files matched your search

-24
View File
@@ -105,30 +105,6 @@ impl Cache {
.messages.push(msg);
}
pub async fn setup_websocket(&mut self, url: String, chan_id: u64) {
use crate::log;
// Ignore inactive server state & NoneType<Jwt>
if let None = self.active_server { return; }
match connect_async(url.clone()).await {
Ok((ws, _)) => {
let (_tx, rx) = ws.split();
let reader = rx.for_each(move |message| {
let msg = message.unwrap().into_text().unwrap();
let msg = api::Message::bogus(msg);
log::file(&msg);
self.new_message(msg, url.clone(), chan_id);
nop()
});
//tokio::spawn(reader);
},
Err(e) => {
log::plain(format!("{}: {}\n", e, url))
}
};
}
pub async fn switch_server(&mut self, host: &str) -> (Command, Option<String>) {
// TODO: clean this func to be less ugly/easier to read
let mut found = false;
+1 -1
View File
@@ -231,7 +231,7 @@ async fn main() -> Result<(), Box<dyn Error>> {
if let Some((url, id)) = app.cache.find_serv(url_portion) {
let (cmd, jwt) = app.cache.switch_server(url.as_str()).await;
let url = net::ws_url(url.as_str(), jwt);
app.cache.setup_websocket(url, id).await;
// maybe hook some message passing listener here?
cmd
} else {
Command::Failure("No server found".into())