Connection

This commit is contained in:
Alex Emmet 2025-09-06 22:34:33 +02:00
commit 6cd859953e
4 changed files with 134 additions and 92 deletions

View file

@ -1,9 +1,6 @@
use std::time::Duration;
use std::collections::HashMap;
use uuid::Uuid;
use request::blocking::{Client, Response};
use request::header::CONTENT_TYPE;
use uuid::{uuid, Uuid};
use reqwest::header::CONTENT_TYPE;
use json::JsonValue;
use reqwest::{Client, Response};

View file

@ -27,18 +27,16 @@ async fn main() {
CommunicationValue::new(
CommunicationType::Identification
)
.add_data(DataTypes::UserIds, json::JsonValue::String(Uuid::new_v4().to_string()))
.add_data(DataTypes::IotaId, json::JsonValue::String(Uuid::new_v4().to_string()))
.add_data(DataTypes::UserIds, Uuid::new_v4().to_string())
.add_data(DataTypes::IotaId, Uuid::new_v4().to_string())
.to_json()
.to_string()
.as_mut()
.to_string()
).await;
omikron.close().await;
);
let mut child = Command::new("sleep").arg("2").spawn().unwrap();
let mut child = Command::new("sleep").arg("5").spawn().unwrap();
let _result = child.wait().unwrap();
omikron.close().await;
println!("reached end of main");
}

View file

@ -1,5 +1,6 @@
use futures_util::{SinkExt, StreamExt};
use std::collections::HashMap;
use std::ptr::write;
use std::str::FromStr;
use std::sync::Arc;
use std::time::{SystemTime, UNIX_EPOCH};
@ -219,7 +220,9 @@ impl OmikronConnection {
}
});
}
pub fn send_message(&self, msg: String){
OmikronConnection::send_message_static(&self.writer, msg);
}
pub async fn send_message_static(
writer: &Arc<Mutex<Option<futures_util::stream::SplitSink<WebSocketStream<MaybeTlsStream<TcpStream>>, Message>>>>,
msg: String,