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:
parent
102c3b2a10
commit
3708d2cd08
@ -105,30 +105,6 @@ impl Cache {
|
|||||||
.messages.push(msg);
|
.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>) {
|
pub async fn switch_server(&mut self, host: &str) -> (Command, Option<String>) {
|
||||||
// TODO: clean this func to be less ugly/easier to read
|
// TODO: clean this func to be less ugly/easier to read
|
||||||
let mut found = false;
|
let mut found = false;
|
||||||
|
@ -231,7 +231,7 @@ async fn main() -> Result<(), Box<dyn Error>> {
|
|||||||
if let Some((url, id)) = app.cache.find_serv(url_portion) {
|
if let Some((url, id)) = app.cache.find_serv(url_portion) {
|
||||||
let (cmd, jwt) = app.cache.switch_server(url.as_str()).await;
|
let (cmd, jwt) = app.cache.switch_server(url.as_str()).await;
|
||||||
let url = net::ws_url(url.as_str(), jwt);
|
let url = net::ws_url(url.as_str(), jwt);
|
||||||
app.cache.setup_websocket(url, id).await;
|
// maybe hook some message passing listener here?
|
||||||
cmd
|
cmd
|
||||||
} else {
|
} else {
|
||||||
Command::Failure("No server found".into())
|
Command::Failure("No server found".into())
|
||||||
|
Loading…
Reference in New Issue
Block a user