core: Message Clone + ServiceManager Broadcast 完整实现

张明远交付:
- Message/PlayerCommand/WifiCommand/Destination 加 derive(Clone)
- Broadcast 分支遍历所有插件转发 msg.clone()
- running 标志控制主循环
- Manager 收到 Shutdown 时先广播给所有插件再停
- cargo check 零 warning

Co-Authored-By: GPT-5.4 <noreply@openai.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
showen
2026-03-12 05:42:53 +08:00
parent b806c71dad
commit 98ba7704dd
2 changed files with 51 additions and 14 deletions

View File

@@ -9,6 +9,7 @@ pub struct Envelope {
}
/// 消息目的地
#[derive(Clone)]
pub enum Destination {
/// 点对点发送给指定插件
Plugin(&'static str),
@@ -19,12 +20,19 @@ pub enum Destination {
}
/// 所有插件间通信的类型安全消息
#[derive(Clone)]
pub enum Message {
// ── 播放控制 ──
PlayerCommand(PlayerCommand),
PlayerStatus(PlayerStatusData),
Trigger { name: String, value: String },
StateChanged { old_state: String, new_state: String },
Trigger {
name: String,
value: String,
},
StateChanged {
old_state: String,
new_state: String,
},
// ── 屏幕管理 ──
ScreenLockRequest(bool),
@@ -33,7 +41,10 @@ pub enum Message {
// ── 网络 ──
WifiCommand(WifiCommand),
WifiResult(String),
WifiProvisioned { ssid: String, ip: String },
WifiProvisioned {
ssid: String,
ip: String,
},
// ── 配置 ──
ConfigReloaded(Arc<AppConfig>),
@@ -44,9 +55,13 @@ pub enum Message {
PluginReady(&'static str),
// ── 扩展(未来插件用) ──
Custom { kind: String, payload: String },
Custom {
kind: String,
payload: String,
},
}
#[derive(Clone)]
pub enum PlayerCommand {
Play,
Pause,
@@ -66,6 +81,7 @@ pub struct PlayerStatusData {
pub current_video: Option<String>,
}
#[derive(Clone)]
pub enum WifiCommand {
Scan,
Connect { ssid: String, password: String },