Enqueue a frame for delivery to `session_id`. Uses `try_send` so callers are never blocked. If the channel is full, the frame is dropped and `frames_dropped` is incremented. The Lite device recovers via snapshot catch-up on reconnect.
(&self, session_id: &str, frame: ArrayFrame)
| 80 | /// full, the frame is dropped and `frames_dropped` is incremented. |
| 81 | /// The Lite device recovers via snapshot catch-up on reconnect. |
| 82 | pub fn enqueue(&self, session_id: &str, frame: ArrayFrame) { |
| 83 | let sessions = self.sessions.read().unwrap_or_else(|p| p.into_inner()); |
| 84 | if let Some(tx) = sessions.get(session_id) { |
| 85 | match tx.try_send(frame) { |
| 86 | Ok(()) => {} |
| 87 | Err(mpsc::error::TrySendError::Full(_)) => { |
| 88 | self.frames_dropped.fetch_add(1, Ordering::Relaxed); |
| 89 | warn!( |
| 90 | session = %session_id, |
| 91 | "array_delivery: channel full — frame dropped; Lite will catch up via snapshot" |
| 92 | ); |
| 93 | } |
| 94 | Err(mpsc::error::TrySendError::Closed(_)) => { |
| 95 | debug!(session = %session_id, "array_delivery: session channel closed (disconnected)"); |
| 96 | } |
| 97 | } |
| 98 | } |
| 99 | } |
| 100 | |
| 101 | /// Number of currently registered sessions. |
| 102 | pub fn active_sessions(&self) -> usize { |