feat(server): 初始化 rtty-server 项目结构与基础依赖

This commit is contained in:
2026-07-31 16:38:02 +08:00
parent c78bfd39ec
commit 01b3bea1c6
11 changed files with 159 additions and 2 deletions

27
src/ws/protocol.rs Normal file
View File

@@ -0,0 +1,27 @@
use serde::{Deserialize, Serialize};
/// 客户端发送给 Rtty 服务端的控制指令
#[derive(Debug, Deserialize)]
#[serde(tag = "type", rename_all = "snake_case")]
pub enum ClientMessage {
/// 键盘/文本输入
Input { data: String },
/// 客户端请求 Resize
Resize { cols: u16, rows: u16 },
/// 客户端申明控制权 (用来解决多端控制冲突)
ClaimControl,
}
/// 服务端推送给客户端的消息 (分别适配 PC 和 移动端)
#[derive(Debug, Serialize)]
#[serde(tag = "type", rename_all = "snake_case")]
pub enum ServerMessage {
/// 原生 ANSI 字节流 (供 PC 端 xterm/flutter_alacritty 渲染)
RawData { data: String },
/// 移动端专属:解耦后的语义化 JSON 屏显数据
MobileSnapshot {
cursor_x: usize,
cursor_y: usize,
lines: Vec<String>,
},
}