XNet/XNet.Business/Dto/SyncMsg.cs
2025-12-28 17:28:40 +08:00

44 lines
1.2 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;
using XNet.Business.Net;
namespace XNet.Business
{
// WebSocket消息类型枚举
public enum WsMsgType
{
SubscribeInstance = 1, // 客户端订阅实例
AgentPositionSync = 2 // 服务端推送Agent位置
}
// 客户端订阅实例的请求消息
[MessagePackObject]
public class SubscribeInstanceReq
{
[Key("instanceId")]
public string InstanceId { get; set; } = string.Empty;
}
// Agent位置同步消息服务端推送
[MessagePackObject]
public class AgentPositionSyncMsg
{
[Key("instanceId")]
public string InstanceId { get; set; } = string.Empty;
[Key("agentIdx")]
public int AgentIdx { get; set; }
[Key("position")]
public Vector3Msg Position { get; set; }
[Key("rotation")]
public float Rotation { get; set; } // 简化为绕Y轴旋转弧度
}
// WebSocket通用消息包装
[MessagePackObject]
public class WsMessage
{
[Key("type")]
public WsMsgType Type { get; set; } = WsMsgType.SubscribeInstance;
[Key("data")]
public byte[] Data { get; set; } = [];
}
}