[Fix] Hopefully omikron - iota comms work now ._.
This commit is contained in:
parent
9699147fa8
commit
b6ec165558
4 changed files with 215 additions and 44 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in a new issue