Files
Ayay/SHH.Contracts/CommandResult.cs
wilson 3351ae739e 在 AiVideo 中能看到图像
增加了在线状态同步逻辑
2026-01-09 12:30:36 +08:00

86 lines
2.3 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.
using MessagePack;
namespace SHH.Contracts
{
/// <summary>
/// 通用指令执行结果 (Response)
/// </summary>
[MessagePackObject]
public class CommandResult
{
#region --- 0. ---
[Key(0)]
public string Protocol { get; set; } = "COMMAND_RESULT";
#endregion
#region --- ---
/// <summary>
/// 回执 ID (必须与请求包的 RequestId 一致)
/// <para>客户端靠这个 ID 来找到对应的 await Task</para>
/// </summary>
[Key(1)]
public string RequestId { get; set; }
#endregion
#region --- ---
/// <summary>
/// 执行是否成功
/// </summary>
[Key(2)]
public bool Success { get; set; }
/// <summary>
/// 结果消息 (成功提示或错误原因)
/// </summary>
[Key(3)]
public string Message { get; set; }
/// <summary>
/// 返回的数据 (JSON 或 Base64 字符串)
/// <para>示例: 截图的 Base64或者查询到的设备列表 JSON</para>
/// </summary>
[Key(4)]
public string Data { get; set; }
#endregion
#region --- ---
/// <summary>
/// 全链路耗时 (毫秒)
/// <para>从客户端发出指令,到收到服务端回执的总时长</para>
/// <para>注意:该字段由客户端收到回执后自动计算填充,服务端不需要赋值</para>
/// </summary>
[Key(5)]
public double ElapsedMilliseconds { get; set; }
#endregion
/// <summary>
/// 时间戳
/// </summary>
[Key(6)]
public long Timestamp { get; set;}
#region --- ---
/// <summary>
/// 快速创建一个成功的回执
/// </summary>
public static CommandResult Ok(string msg = "OK", string data = null)
=> new CommandResult { Success = true, Message = msg, Data = data };
/// <summary>
/// 快速创建一个失败的回执
/// </summary>
public static CommandResult Fail(string msg)
=> new CommandResult { Success = false, Message = msg };
#endregion
}
}