45 lines
1.2 KiB
C#
45 lines
1.2 KiB
C#
using MessagePack;
|
||
using System.Numerics;
|
||
using System.Text.Json;
|
||
|
||
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 Vector3 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; } = string.Empty;
|
||
}
|
||
} |