You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

48 lines
1.4 KiB

use std::{sync::mpsc::channel, thread::spawn};
use app::App;
use eframe::egui::{self};
use tungstenite::{connect, Message};
mod app;
fn main() {
let address = std::env::args().nth(1).expect("No url given!");
if let Ok(ws) = connect(address) {
let (mut socket, _) = ws;
let (tx, rx) = channel();
spawn(move || loop {
let message = socket.read_message();
if let Ok(message) = message {
if message.to_string() == "__PING__" {
socket
.write_message(Message::Text("__PONG__".to_string()))
.expect("Failed to respond to ping! Did the WebSocket server die?");
} else {
tx.send(message)
.expect("Failed to send message to channel! (This shouldn't be possible)");
}
}
});
eframe::run_native(
"Log Viewer",
eframe::NativeOptions::default(),
Box::new(|cc| {
let mut fonts = egui::FontDefinitions::default();
fonts.font_data.iter_mut().for_each(|font| {
font.1.tweak.scale = 2.0;
});
cc.egui_ctx.set_fonts(fonts);
Box::new(App::new(rx))
}),
);
} else {
panic!("Could not connect to websocket!");
}
}