vdi-cloud/terminal/kiosk-shell/src/state_machine.h
dev 589cde457c feat(kiosk-shell): FreeRDP 3 内嵌客户端跑通,登录页可进入远程桌面
- 按方案 3.2/3.3 节以 libfreerdp3 API 内嵌,不拉起外部进程
- gdi_init 移到 PostConnect(提前调用会段错误)
- 去掉 ContextSize 扩展 rdpContext,改用 freerdp* 注册表 + gfx->custom
- NLA 认证传空字符串而非 nullptr,修复 SEC_E_NO_CREDENTIALS
- 补充 FreeRDP3 内嵌实现笔记文档
2026-10-23 18:57:05 +08:00

63 lines
1.8 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// kiosk-shell 状态机
//
// 对应《VDI 云桌面软件开发方案》3.2 节:
// 状态机:BOOT -> CONFIG(无配置)-> CONNECTING -> SESSION(嵌入 freerdp 窗口)
// -> RECONNECT -> ERROR
//
// 状态转换规则:
// BOOT 进程启动,读取本地配置
// CONFIG 无可用配置或用户停留在登录页,等待输入
// CONNECTING 正在建立 RDP 连接
// SESSION 远程会话进行中
// RECONNECT 会话意外断开,等待重连
// ERROR 不可恢复错误,提示后回到 CONFIG
#ifndef KIOSK_SHELL_STATE_MACHINE_H
#define KIOSK_SHELL_STATE_MACHINE_H
#include <QString>
#include <functional>
#include <string>
namespace vdi {
enum class State {
kBoot, // 启动中
kConfig, // 首配 / 登录页
kConnecting, // 连接中
kSession, // 会话中
kReconnect, // 断线等待重连
kError, // 错误
};
const char* stateToString(State s);
class StateMachine {
public:
// 状态说明使用 QString,便于直接显示在状态条上
using StateListener = std::function<void(State from, State to, const QString& detail)>;
explicit StateMachine(StateListener listener = nullptr);
State current() const { return current_; }
bool isIn(State s) const { return current_ == s; }
// 尝试切换到目标状态;非法转换会被拒绝并返回 false
bool transitionTo(State next, const QString& detail = QString());
// 当前状态下允许执行的动作
bool canConnect() const;
bool canDisconnect() const;
bool canRetry() const;
private:
static bool isLegalTransition(State from, State to);
State current_ = State::kBoot;
StateListener listener_;
};
} // namespace vdi
#endif // KIOSK_SHELL_STATE_MACHINE_H