| 123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- // Prevents additional console window on Windows in release, DO NOT REMOVE!!
- #![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
- // fn main() {
- // app_lib::run();
- // }
- fn main() {
- tauri::Builder::default()
- .invoke_handler(tauri::generate_handler![
- greet,
- receive_messages,
- send_message
- ])
- .run(tauri::generate_context!())
- .expect("error while running tauri application");
- }
- #[tauri::command]
- fn greet(name: &str) -> String {
- format!("Hello, {}!", name)
- }
- #[tauri::command]
- fn receive_messages(hostname: &str, password: &str) -> Vec<(u128, String, String, String)> {
- let msges = client_shared::utils::rx_messages(hostname, password, 2);
- let Ok(msges) = msges else {
- return vec![];
- };
- let mut out = vec![];
- for msg in msges {
- out.push((msg.time, msg.channel, msg.sender, msg.content));
- }
- out
- }
- // TODO: Handle errors
- #[tauri::command]
- fn send_message(channel: &str, sender: &str, content: &str, hostname: &str, password: &str) {
- let message = client_shared::message::Message::new(sender, content, channel);
- let _ = client_shared::utils::tx_message(hostname, password, 2, message);
- }
|