mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2026-02-02 02:51:53 +08:00
feat: 完善架构优化性能
- 调整音视频架构,提升 RKMPP 编码 MJPEG-->H264 性能,同时解决丢帧马赛克问题; - 删除多用户逻辑,只保留单用户,支持设置 web 单会话; - 修复删除体验不好的的回退逻辑,前端页面菜单位置微调; - 增加 OTG USB 设备动态调整功能; - 修复 mdns 问题,webrtc 视频切换更顺畅。
This commit is contained in:
25
src/state.rs
25
src/state.rs
@@ -1,4 +1,4 @@
|
||||
use std::sync::Arc;
|
||||
use std::{collections::VecDeque, sync::Arc};
|
||||
use tokio::sync::{broadcast, RwLock};
|
||||
|
||||
use crate::atx::AtxController;
|
||||
@@ -56,6 +56,8 @@ pub struct AppState {
|
||||
pub events: Arc<EventBus>,
|
||||
/// Shutdown signal sender
|
||||
pub shutdown_tx: broadcast::Sender<()>,
|
||||
/// Recently revoked session IDs (for client kick detection)
|
||||
pub revoked_sessions: Arc<RwLock<VecDeque<String>>>,
|
||||
/// Data directory path
|
||||
data_dir: std::path::PathBuf,
|
||||
}
|
||||
@@ -92,6 +94,7 @@ impl AppState {
|
||||
extensions,
|
||||
events,
|
||||
shutdown_tx,
|
||||
revoked_sessions: Arc::new(RwLock::new(VecDeque::new())),
|
||||
data_dir,
|
||||
})
|
||||
}
|
||||
@@ -106,6 +109,26 @@ impl AppState {
|
||||
self.shutdown_tx.subscribe()
|
||||
}
|
||||
|
||||
/// Record revoked session IDs (bounded queue)
|
||||
pub async fn remember_revoked_sessions(&self, session_ids: Vec<String>) {
|
||||
if session_ids.is_empty() {
|
||||
return;
|
||||
}
|
||||
let mut guard = self.revoked_sessions.write().await;
|
||||
for id in session_ids {
|
||||
guard.push_back(id);
|
||||
}
|
||||
while guard.len() > 32 {
|
||||
guard.pop_front();
|
||||
}
|
||||
}
|
||||
|
||||
/// Check if a session ID was revoked (kicked)
|
||||
pub async fn is_session_revoked(&self, session_id: &str) -> bool {
|
||||
let guard = self.revoked_sessions.read().await;
|
||||
guard.iter().any(|id| id == session_id)
|
||||
}
|
||||
|
||||
/// Get complete device information for WebSocket clients
|
||||
///
|
||||
/// This method collects the current state of all devices (video, HID, MSD, ATX, Audio)
|
||||
|
||||
Reference in New Issue
Block a user