提交帧同步案例

This commit is contained in:
PC-20230316NUNE\Administrator
2024-01-26 19:15:07 +08:00
parent 3a345ab966
commit 68c4d5e811
3928 changed files with 463020 additions and 1 deletions

View File

@@ -0,0 +1,41 @@
using System;
using System.Linq;
using System.Reflection;
using Google.Protobuf;
using Plugins.JNGame.Network.Entity;
using Plugins.JNGame.Util;
namespace Plugins.JNGame.Network.Util
{
// 网络数据工具类 [请求Id*4,处理Id*4,...参数数据*N]
public static class NDataUtil
{
// 解析
public static JNetParam Parse(byte[] data)
{
return JNetParam.Build(
ToUtil.Byte4ToInt(data.Skip(0).Take(4).ToArray()),
ToUtil.Byte4ToInt(data.Skip(4).Take(4).ToArray()))
.SetByte(data.Skip(8).Take(data.Length - 8).ToArray());
}
// 编码
public static byte[] Encrypt(JNetParam param)
{
byte[] hId = ToUtil.IntToByte4(param.HId);
byte[] id = ToUtil.IntToByte4(param.ID);
byte[] data = Array.Empty<byte>();
if(param.Data != null)
data = param.Data.ToByteArray();
return id.Concat(hId).Concat(data).ToArray();
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 8b05544adb2f44b4af8f86b2bc66a035
timeCreated: 1706004790