[Fix] Hopefully omikron - iota comms work now ._.

This commit is contained in:
Alex Emmet 2026-03-26 02:01:26 +01:00
commit b6ec165558
4 changed files with 215 additions and 44 deletions

View file

@ -1,5 +1,5 @@
use crate::APP_STATE;
use crate::omikron::omikron_connection::OmikronConnection;
use crate::{APP_STATE, log};
use dashmap::DashMap;
use std::sync::LazyLock;
use std::time::Instant;
@ -13,6 +13,13 @@ impl OmikronConnection {
pub async fn send_ping(&self) {
let id = rand_u32();
log!(
"OmikronConnection::send_ping [id={}, ptr={:p}, ping_id={}]",
self.connection_id,
self,
id
);
PING_TIMES.insert(id, Instant::now());
// Auto-cleanup old pings (optional)
@ -31,6 +38,13 @@ impl OmikronConnection {
pub async fn handle_pong(&self, cv: &CommunicationValue) {
let id = cv.get_id();
log!(
"OmikronConnection::handle_pong [id={}, ptr={:p}, ping_id={}]",
self.connection_id,
self,
id
);
if let Some((_, send_time)) = PING_TIMES.remove(&id) {
let ping_ms = Instant::now().duration_since(send_time).as_millis() as i64;
*self.last_ping.lock().await = ping_ms;