mirror of
https://github.com/Alex-Rachel/TEngine.git
synced 2025-08-07 16:45:10 +00:00
[+] Network
[+] Network
This commit is contained in:
30
Assets/GameScripts/HotFix/GameLogic/Network/ProtoUtil.cs
Normal file
30
Assets/GameScripts/HotFix/GameLogic/Network/ProtoUtil.cs
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
using System;
|
||||||
|
using GameProto;
|
||||||
|
|
||||||
|
namespace GameLogic
|
||||||
|
{
|
||||||
|
public class ProtoUtil
|
||||||
|
{
|
||||||
|
public static UInt32 MsgEcho = 0;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 根据msgId来生成一个数据包
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="msgId"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static CSPkg BuildCsMsg(int msgId)
|
||||||
|
{
|
||||||
|
CSPkg tmp = new CSPkg();
|
||||||
|
tmp.Head = new CSPkgHead();
|
||||||
|
tmp.Head.MsgId = (UInt16)msgId;
|
||||||
|
tmp.Head.Echo = GetNextEcho();
|
||||||
|
// tmp.Body.create(msgId);
|
||||||
|
return tmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static UInt32 GetNextEcho()
|
||||||
|
{
|
||||||
|
return ++MsgEcho;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 4d4427af9be14c56b01e4674853c09a8
|
||||||
|
timeCreated: 1684334469
|
@@ -15,6 +15,10 @@ namespace GameProto
|
|||||||
{
|
{
|
||||||
public partial class NetMsgId
|
public partial class NetMsgId
|
||||||
{
|
{
|
||||||
|
//心跳请求
|
||||||
|
public const int CS_CMD_HEATBEAT_REQ = 1001;
|
||||||
|
//心跳回包
|
||||||
|
public const int CS_CMD_HEATBEAT_RES = 1002;
|
||||||
//帐号登录请求
|
//帐号登录请求
|
||||||
public const int CS_CMD_ACT_LOGIN_REQ = 2001;
|
public const int CS_CMD_ACT_LOGIN_REQ = 2001;
|
||||||
//帐号登录回包
|
//帐号登录回包
|
||||||
|
@@ -13,71 +13,68 @@ using System.Collections.Generic;
|
|||||||
|
|
||||||
namespace GameProto
|
namespace GameProto
|
||||||
{
|
{
|
||||||
// 这个文件只放协议,和协议头
|
// 这个文件只放协议,和协议头
|
||||||
// 消息协议
|
// 消息协议
|
||||||
[Serializable,global::ProtoBuf.ProtoContract(Name = @"CSPkg")]
|
[Serializable,global::ProtoBuf.ProtoContract(Name = @"CSPkg")]
|
||||||
public partial class CSPkg
|
public partial class CSPkg
|
||||||
{
|
{
|
||||||
[global::ProtoBuf.ProtoMember(1)]
|
[global::ProtoBuf.ProtoMember(1)]
|
||||||
public CSPkgHead Head { get; set; }
|
public CSPkgHead Head { get; set; }
|
||||||
|
|
||||||
[global::ProtoBuf.ProtoMember(2)]
|
[global::ProtoBuf.ProtoMember(2)]
|
||||||
public CSPkgBody Body { get; set; }
|
public CSPkgBody Body { get; set; }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 消息协议头
|
// 消息协议头
|
||||||
[Serializable,global::ProtoBuf.ProtoContract(Name = @"CSPkgHead")]
|
[Serializable,global::ProtoBuf.ProtoContract(Name = @"CSPkgHead")]
|
||||||
public partial class CSPkgHead
|
public partial class CSPkgHead
|
||||||
{
|
{
|
||||||
[global::ProtoBuf.ProtoMember(1)]
|
[global::ProtoBuf.ProtoMember(1)]
|
||||||
public uint MsgId { get; set; }
|
public uint MsgId { get; set; }
|
||||||
|
|
||||||
[global::ProtoBuf.ProtoMember(2)]
|
[global::ProtoBuf.ProtoMember(2)]
|
||||||
public uint MsgLength { get; set; }
|
public uint MsgLength { get; set; }
|
||||||
|
|
||||||
[global::ProtoBuf.ProtoMember(3)]
|
[global::ProtoBuf.ProtoMember(3)]
|
||||||
public uint MsgVersion { get; set; }
|
public uint MsgVersion { get; set; }
|
||||||
|
|
||||||
[global::ProtoBuf.ProtoMember(4)]
|
[global::ProtoBuf.ProtoMember(4)]
|
||||||
public uint Echo { get; set; }
|
public uint Echo { get; set; }
|
||||||
|
|
||||||
[global::ProtoBuf.ProtoMember(5)]
|
[global::ProtoBuf.ProtoMember(5)]
|
||||||
public uint SvrTime { get; set; }
|
public uint SvrTime { get; set; }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 消息协议体
|
// 消息协议体
|
||||||
[Serializable,global::ProtoBuf.ProtoContract(Name = @"CSPkgBody")]
|
[Serializable,global::ProtoBuf.ProtoContract(Name = @"CSPkgBody")]
|
||||||
public partial class CSPkgBody
|
public partial class CSPkgBody
|
||||||
{
|
{
|
||||||
[global::ProtoBuf.ProtoMember(1)]
|
[global::ProtoBuf.ProtoMember(1)]
|
||||||
public CSActLoginReq ActLoginReq { get; set; }
|
public CSHeatBeatReq HeatBeatReq { get; set; }
|
||||||
|
|
||||||
[global::ProtoBuf.ProtoMember(2)]
|
[global::ProtoBuf.ProtoMember(2)]
|
||||||
public CSActLoginRes ActLoginRes { get; set; }
|
public CSHeatBeatRes HeatBeatRes { get; set; }
|
||||||
|
|
||||||
}
|
[global::ProtoBuf.ProtoMember(3)]
|
||||||
|
public CSActLoginReq ActLoginReq { get; set; }
|
||||||
|
|
||||||
// 消息结果
|
[global::ProtoBuf.ProtoMember(4)]
|
||||||
[Serializable,global::ProtoBuf.ProtoContract(Name = @"ProtoResult")]
|
public CSActLoginRes ActLoginRes { get; set; }
|
||||||
public partial class ProtoResult
|
|
||||||
{
|
|
||||||
[global::ProtoBuf.ProtoMember(3)]
|
|
||||||
public List<string> Params = new List<string>();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 协议ID
|
// 协议ID
|
||||||
[global::ProtoBuf.ProtoContract()]
|
[global::ProtoBuf.ProtoContract()]
|
||||||
public enum CSMsgID
|
public enum CSMsgID
|
||||||
{
|
{
|
||||||
CS_START = 0,
|
CS_START = 0,
|
||||||
|
|
||||||
CS_HeartBeat = 10001,
|
CS_HeartBeat = 10001,
|
||||||
|
|
||||||
CS_END = 10000,
|
CS_END = 10000,
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@@ -0,0 +1,44 @@
|
|||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// <auto-generated>
|
||||||
|
// This code was generated by a tool.
|
||||||
|
// Changes to this file may cause incorrect behavior and will be lost if
|
||||||
|
// the code is regenerated.
|
||||||
|
// </auto-generated>
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using ProtoBuf;
|
||||||
|
using TEngine;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace GameProto
|
||||||
|
{
|
||||||
|
// 常用协议
|
||||||
|
// 消息结果
|
||||||
|
[Serializable,global::ProtoBuf.ProtoContract(Name = @"ProtoResult")]
|
||||||
|
public partial class ProtoResult
|
||||||
|
{
|
||||||
|
[global::ProtoBuf.ProtoMember(3)]
|
||||||
|
public List<string> Params = new List<string>();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// 心跳请求
|
||||||
|
[Serializable,global::ProtoBuf.ProtoContract(Name = @"CSHeatBeatReq")]
|
||||||
|
public partial class CSHeatBeatReq
|
||||||
|
{
|
||||||
|
[global::ProtoBuf.ProtoMember(1)]
|
||||||
|
public float HeatEchoTime { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// 角色登录结果返回
|
||||||
|
[Serializable,global::ProtoBuf.ProtoContract(Name = @"CSHeatBeatRes")]
|
||||||
|
public partial class CSHeatBeatRes
|
||||||
|
{
|
||||||
|
[global::ProtoBuf.ProtoMember(1)]
|
||||||
|
public float HeatEchoTime { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 12409798b7e6e134ea804286b9670089
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
@@ -13,7 +13,7 @@ using System.Collections.Generic;
|
|||||||
|
|
||||||
namespace GameProto
|
namespace GameProto
|
||||||
{
|
{
|
||||||
// 这个文件只放协议,和协议头
|
// 玩家协议
|
||||||
// 角色登录结果请求
|
// 角色登录结果请求
|
||||||
[Serializable,global::ProtoBuf.ProtoContract(Name = @"CSActLoginReq")]
|
[Serializable,global::ProtoBuf.ProtoContract(Name = @"CSActLoginReq")]
|
||||||
public partial class CSActLoginReq
|
public partial class CSActLoginReq
|
||||||
|
Reference in New Issue
Block a user