OmikronConnector hotfix

This commit is contained in:
Jonathan Wanke 2025-09-01 23:31:41 +02:00
commit 7349d87388
8 changed files with 398 additions and 40 deletions

0
src/gui/mod.rs Normal file
View file

View file

@ -1,6 +1,5 @@
use std::time::Duration;
use json::{self, JsonValue};
use tokio::time::sleep;
use json;
use tokio::runtime::Runtime;
use uuid::Uuid;
mod data;
@ -8,13 +7,13 @@ mod omikron;
mod util;
mod users;
use crate::omikron::omikronConnection::{OmikronConnection};
use crate::data::communication::{CommunicationValue, LogLevel, LogValue, CommunicationType, DataTypes};
use crate::omikron::omikron_connection::{OmikronConnection};
use crate::data::communication::{CommunicationValue, CommunicationType, DataTypes};
fn main() {
let rt = tokio::runtime::Runtime::new().unwrap();
let omikron = OmikronConnection::new();
rt.block_on(async {
let runtime: Runtime = tokio::runtime::Runtime::new().unwrap();
let omikron: OmikronConnection = OmikronConnection::new();
runtime.block_on(async {
omikron.connect().await;
omikron.send_message(
@ -26,6 +25,7 @@ fn main() {
.to_json()
.to_string()
.as_mut()
.to_string()
).await;
omikron.close().await;
});

View file

@ -1 +1 @@
pub mod omikronConnection;
pub mod omikron_connection;

View file

@ -1,9 +1,12 @@
use futures_util::{SinkExt, StreamExt};
use tokio_tungstenite::tungstenite::Utf8Bytes;
use std::collections::HashMap;
use std::io::Bytes;
use std::sync::Arc;
use tokio::sync::Mutex;
use tokio::net::TcpStream;
use tokio::time::{sleep, Duration};
use bytes;
use tokio_tungstenite::{
connect_async,
tungstenite::protocol::Message,
@ -111,10 +114,10 @@ impl OmikronConnection {
});
}
pub async fn send_message(&self, msg: &str) {
pub async fn send_message<'a>(&self, msg: String) {
let mut guard = self.writer.lock().await;
if let Some(writer) = guard.as_mut() {
if let Err(e) = writer.send(Message::Text(msg.to_string())).await {
if let Err(e) = writer.send(Message::Text(Utf8Bytes::from(msg))).await {
println!("[Omikron] Send failed: {}", e);
}
}

View file

@ -5,7 +5,6 @@ use std::io::{Read, Write};
use std::path::Path;
use uuid::Uuid;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum MessageState {
Read,
Received,

View file

@ -1,4 +1,4 @@
pub mod fileUtil;
pub mod chatFiles;
pub mod configUtil;
pub mod chatsUtil;
pub mod file_util;
pub mod chat_files;
pub mod config_util;
pub mod chats_util;