2024-02-04 16:17:39 +08:00
|
|
|
|
using System;
|
|
|
|
|
using Cysharp.Threading.Tasks;
|
2024-02-02 15:38:13 +08:00
|
|
|
|
using Plugins.JNGame.Network.Action;
|
2024-01-29 02:28:42 +08:00
|
|
|
|
using Plugins.JNGame.Sync.Frame;
|
|
|
|
|
using UnityEngine;
|
2024-01-26 19:15:07 +08:00
|
|
|
|
|
2024-02-01 19:06:51 +08:00
|
|
|
|
namespace Game.Plugins.App
|
2024-01-26 19:15:07 +08:00
|
|
|
|
{
|
|
|
|
|
public class JNGSyncFrame : JNSyncFrame
|
|
|
|
|
{
|
|
|
|
|
protected override void OnSendInput(JNFrameInputs inputs)
|
|
|
|
|
{
|
2024-02-02 15:38:13 +08:00
|
|
|
|
//发送帧数据给服务端
|
|
|
|
|
App.Socket.Send((int)NActionEnum.NSyncFrameInput,inputs);
|
2024-01-26 19:15:07 +08:00
|
|
|
|
}
|
2024-01-29 02:28:42 +08:00
|
|
|
|
|
|
|
|
|
protected override async UniTask<JNFrameInfos> OnServerData(int start, int end)
|
|
|
|
|
{
|
2024-01-30 19:22:27 +08:00
|
|
|
|
Debug.Log($"OnServerData - {start}");
|
2024-02-04 16:17:39 +08:00
|
|
|
|
try
|
2024-01-29 02:28:42 +08:00
|
|
|
|
{
|
2024-02-04 16:17:39 +08:00
|
|
|
|
var data = (await App.Api.GetByte($"/sync/frame?start={start}"));
|
|
|
|
|
if (data is { Length: > 0 })
|
|
|
|
|
{
|
|
|
|
|
JNFrameInfos info = JNFrameInfos.Parser.ParseFrom(data);
|
|
|
|
|
Debug.Log($"OnServerData - {start} 结束");
|
|
|
|
|
return info;
|
|
|
|
|
}
|
2024-01-29 02:28:42 +08:00
|
|
|
|
}
|
2024-02-04 16:17:39 +08:00
|
|
|
|
catch(Exception e)
|
2024-01-29 02:28:42 +08:00
|
|
|
|
{
|
2024-02-04 16:17:39 +08:00
|
|
|
|
// ignored
|
|
|
|
|
Debug.LogError(e.Message);
|
2024-01-29 02:28:42 +08:00
|
|
|
|
}
|
2024-02-04 16:17:39 +08:00
|
|
|
|
|
|
|
|
|
return new JNFrameInfos();
|
2024-01-29 02:28:42 +08:00
|
|
|
|
}
|
2024-01-26 19:15:07 +08:00
|
|
|
|
}
|
|
|
|
|
}
|