diff --git a/Assets/TEngine/Runtime/UI/Demo/TEngineUI.cs b/Assets/TEngine/Runtime/UI/Demo/TEngineUI.cs index 2e338546..27ab4f02 100644 --- a/Assets/TEngine/Runtime/UI/Demo/TEngineUI.cs +++ b/Assets/TEngine/Runtime/UI/Demo/TEngineUI.cs @@ -41,6 +41,7 @@ public class TEngineUI : UIWindow protected override void OnUpdate() { + TEngineHotUpdate.GameLogicMain.Update(); TLogger.LogInfo("TEngineUI OnUpdate"); } diff --git a/TEngineHotUpdate/GameApp.cs b/TEngineHotUpdate/GameApp.cs index f4e8dc0b..2981e40e 100644 --- a/TEngineHotUpdate/GameApp.cs +++ b/TEngineHotUpdate/GameApp.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using UnityEngine; -using UnityEngine.UI; +using TEngineCore; namespace TEngineHotUpdate { @@ -12,32 +6,32 @@ namespace TEngineHotUpdate { public static void Init() { - Debug.Log("Init"); + GameTime.StartFrame(); } public static void Start() { - Debug.Log("Start"); + GameTime.StartFrame(); } public static void Update() { - Debug.Log("Update"); + GameTime.StartFrame(); } public static void LateUpdate() { - Debug.Log("LateUpdate"); + GameTime.StartFrame(); } public static void Destroy() { - + GameTime.StartFrame(); } public static void OnApplicationPause(bool isPause) { - + GameTime.StartFrame(); } } } diff --git a/TEngineHotUpdate/TEngineHotUpdate.csproj b/TEngineHotUpdate/TEngineHotUpdate.csproj index 1dcb47a2..a3353efe 100644 --- a/TEngineHotUpdate/TEngineHotUpdate.csproj +++ b/TEngineHotUpdate/TEngineHotUpdate.csproj @@ -1,5 +1,6 @@  - + Debug @@ -56,6 +57,12 @@ UnityLib\UnityEngine.InputLegacyModule.dll + + UnityLib\protobuf-net.dll + + + UnityLib\Google.Protobuf.dll + @@ -68,6 +75,7 @@ + diff --git a/TEngineHotUpdate/UnityLib/Google.Protobuf.dll b/TEngineHotUpdate/UnityLib/Google.Protobuf.dll new file mode 100644 index 00000000..cd21d360 Binary files /dev/null and b/TEngineHotUpdate/UnityLib/Google.Protobuf.dll differ diff --git a/TEngineHotUpdate/UnityLib/protobuf-net.dll b/TEngineHotUpdate/UnityLib/protobuf-net.dll new file mode 100644 index 00000000..3562db52 Binary files /dev/null and b/TEngineHotUpdate/UnityLib/protobuf-net.dll differ diff --git a/TEngineHotUpdate/src/Proto/TEngineProto.cs b/TEngineHotUpdate/src/Proto/TEngineProto.cs new file mode 100644 index 00000000..ba91837f --- /dev/null +++ b/TEngineHotUpdate/src/Proto/TEngineProto.cs @@ -0,0 +1,2104 @@ +// +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: TEngineProto.proto +// +#pragma warning disable 1591, 0612, 3021 +#region Designer generated code + +using pb = global::Google.Protobuf; +using pbc = global::Google.Protobuf.Collections; +using pbr = global::Google.Protobuf.Reflection; +using scg = global::System.Collections.Generic; +namespace TEngineProto { + + /// Holder for reflection information generated from TEngineProto.proto + public static partial class TEngineProtoReflection { + + #region Descriptor + /// File descriptor for TEngineProto.proto + public static pbr::FileDescriptor Descriptor { + get { return descriptor; } + } + private static pbr::FileDescriptor descriptor; + + static TEngineProtoReflection() { + byte[] descriptorData = global::System.Convert.FromBase64String( + string.Concat( + "ChJURW5naW5lUHJvdG8ucHJvdG8SDFRFbmdpbmVQcm90byLAAgoITWFpblBh", + "Y2sSLgoLcmVxdWVzdGNvZGUYASABKA4yGS5URW5naW5lUHJvdG8uUmVxdWVz", + "dENvZGUSLAoKYWN0aW9uY29kZRgCIAEoDjIYLlRFbmdpbmVQcm90by5BY3Rp", + "b25Db2RlEiwKCnJldHVybmNvZGUYAyABKA4yGC5URW5naW5lUHJvdG8uUmV0", + "dXJuQ29kZRIqCglsb2dpblBhY2sYBCABKAsyFy5URW5naW5lUHJvdG8uTG9n", + "aW5QYWNrEg4KBmV4dHN0chgFIAEoCRIoCghyb29tcGFjaxgGIAMoCzIWLlRF", + "bmdpbmVQcm90by5Sb29tUGFjaxIsCgpwbGF5ZXJwYWNrGAcgASgLMhguVEVu", + "Z2luZVByb3RvLlBsYXllclBhY2sSFAoMSGVhdEVjaG9UaW1lGAggASgCIi8K", + "CUxvZ2luUGFjaxIQCgh1c2VybmFtZRgBIAEoCRIQCghwYXNzd29yZBgCIAEo", + "CSLxAQoIUm9vbVBhY2sSEAoIcm9vbW5hbWUYASABKAkSDgoGbWF4bnVtGAIg", + "ASgFEg4KBmN1cm51bRgDIAEoBRINCgVzdGF0ZRgEIAEoBRIuCglnYW1lc3Rh", + "dGUYBSABKAsyGy5URW5naW5lUHJvdG8uR2FtZVN0YXRlUGFjaxIOCgZyb29t", + "SUQYBiABKAUSDwoHdmlzYWJsZRgJIAEoBRITCgt1c2VQYXNzd29yZBgKIAEo", + "BRIQCghwYXNzd29yZBgLIAEoCRIsCgpwbGF5ZXJwYWNrGAwgAygLMhguVEVu", + "Z2luZVByb3RvLlBsYXllclBhY2sieQoKUGxheWVyUGFjaxISCgpwbGF5ZXJu", + "YW1lGAEgASgJEhAKCHBsYXllcklEGAIgASgJEgoKAmhwGAMgASgFEiYKB3Bv", + "c1BhY2sYBCABKAsyFS5URW5naW5lUHJvdG8uUG9zUGFjaxIRCglwbGF5ZXJK", + "b2IYBSABKAUiRwoNR2FtZVN0YXRlUGFjaxImCgVzdGF0ZRgBIAEoDjIXLlRF", + "bmdpbmVQcm90by5HQU1FU1RBVEUSDgoGQm9zc0lkGAIgASgFIlgKCENhcmRE", + "YXRhEg8KB2NhcmRJbnQYASABKAUSEQoJY2FyZFZhbHVlGAIgASgFEigKCGNh", + "cmRUeXBlGAMgASgOMhYuVEVuZ2luZVByb3RvLkNhcmRUeXBlIq4BCgdQb3NQ", + "YWNrEgwKBFBvc1gYASABKAISDAoEUG9zWRgCIAEoAhIMCgRQb3NaGAMgASgC", + "Eg0KBVJvdGFYGAQgASgCEg0KBVJvdGFZGAUgASgCEg0KBVJvdGFaGAYgASgC", + "EhEKCUFuaW1hdGlvbhgIIAEoBRIMCgREaXJyGAkgASgFEg0KBU1vdmVYGAog", + "ASgCEg0KBU1vdmVZGAsgASgCEg0KBU1vdmVaGAwgASgCKkcKC1JlcXVlc3RD", + "b2RlEg8KC1JlcXVlc3ROb25lEAASCQoFSGVhcnQQARIICgRVc2VyEAISCAoE", + "Um9vbRADEggKBEdhbWUQBCrHAQoKQWN0aW9uQ29kZRIOCgpBY3Rpb25Ob25l", + "EAASDQoJSGVhcnRCZWF0EAESDQoIUmVnaXN0ZXIQ6AcSCgoFTG9naW4Q6QcS", + "DwoKQ3JlYXRlUm9vbRDqBxINCghGaW5kUm9vbRDrBxIPCgpHZXRQbGF5ZXJz", + "EOwHEg0KCEpvaW5Sb29tEO0HEg0KCEV4aXRSb29tEO4HEg4KCVN0YXJ0R2Ft", + "ZRDvBxIVChBTdGFydEdhbWVGcm9tU3ZyEPAHEgkKBENoYXQQ0A8qQwoKUmV0", + "dXJuQ29kZRIOCgpSZXR1cm5Ob25lEAASCwoHU3VjY2VzcxABEggKBEZhaWwQ", + "AhIOCgpNc2dUaW1lT3V0EAMqOwoJR0FNRVNUQVRFEgoKBlNUQVRFMRAAEgoK", + "BlNUQVRFMhABEgoKBlNUQVRFMxACEgoKBlNUQVRFNBADKkwKCENhcmRUeXBl", + "EggKBE5PTkUQABIICgRDTFVCEAESCwoHRElBTU9ORBACEgkKBUhFQVJUEAMS", + "CQoFU1BBREUQBBIJCgVKT0tFUhAFYgZwcm90bzM=")); + descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, + new pbr::FileDescriptor[] { }, + new pbr::GeneratedClrTypeInfo(new[] {typeof(global::TEngineProto.RequestCode), typeof(global::TEngineProto.ActionCode), typeof(global::TEngineProto.ReturnCode), typeof(global::TEngineProto.GAMESTATE), typeof(global::TEngineProto.CardType), }, null, new pbr::GeneratedClrTypeInfo[] { + new pbr::GeneratedClrTypeInfo(typeof(global::TEngineProto.MainPack), global::TEngineProto.MainPack.Parser, new[]{ "Requestcode", "Actioncode", "Returncode", "LoginPack", "Extstr", "Roompack", "Playerpack", "HeatEchoTime" }, null, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::TEngineProto.LoginPack), global::TEngineProto.LoginPack.Parser, new[]{ "Username", "Password" }, null, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::TEngineProto.RoomPack), global::TEngineProto.RoomPack.Parser, new[]{ "Roomname", "Maxnum", "Curnum", "State", "Gamestate", "RoomID", "Visable", "UsePassword", "Password", "Playerpack" }, null, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::TEngineProto.PlayerPack), global::TEngineProto.PlayerPack.Parser, new[]{ "Playername", "PlayerID", "Hp", "PosPack", "PlayerJob" }, null, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::TEngineProto.GameStatePack), global::TEngineProto.GameStatePack.Parser, new[]{ "State", "BossId" }, null, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::TEngineProto.CardData), global::TEngineProto.CardData.Parser, new[]{ "CardInt", "CardValue", "CardType" }, null, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::TEngineProto.PosPack), global::TEngineProto.PosPack.Parser, new[]{ "PosX", "PosY", "PosZ", "RotaX", "RotaY", "RotaZ", "Animation", "Dirr", "MoveX", "MoveY", "MoveZ" }, null, null, null, null) + })); + } + #endregion + + } + #region Enums + public enum RequestCode { + [pbr::OriginalName("RequestNone")] RequestNone = 0, + /// + ///心跳 + /// + [pbr::OriginalName("Heart")] Heart = 1, + /// + ///用户 + /// + [pbr::OriginalName("User")] User = 2, + /// + ///房间 + /// + [pbr::OriginalName("Room")] Room = 3, + /// + ///游戏 + /// + [pbr::OriginalName("Game")] Game = 4, + } + + public enum ActionCode { + [pbr::OriginalName("ActionNone")] ActionNone = 0, + /// + ///心跳 + /// + [pbr::OriginalName("HeartBeat")] HeartBeat = 1, + /// + ///注册 + /// + [pbr::OriginalName("Register")] Register = 1000, + /// + ///登录 + /// + [pbr::OriginalName("Login")] Login = 1001, + /// + ///创建房间 + /// + [pbr::OriginalName("CreateRoom")] CreateRoom = 1002, + /// + ///查找房间 + /// + [pbr::OriginalName("FindRoom")] FindRoom = 1003, + /// + ///获取玩家列表 + /// + [pbr::OriginalName("GetPlayers")] GetPlayers = 1004, + /// + ///加入房间 + /// + [pbr::OriginalName("JoinRoom")] JoinRoom = 1005, + /// + ///离开房间 + /// + [pbr::OriginalName("ExitRoom")] ExitRoom = 1006, + /// + ///开始游戏 + /// + [pbr::OriginalName("StartGame")] StartGame = 1007, + /// + ///服务端发送来的开始游戏指令 + /// + [pbr::OriginalName("StartGameFromSvr")] StartGameFromSvr = 1008, + /// + ///聊天 + /// + [pbr::OriginalName("Chat")] Chat = 2000, + } + + public enum ReturnCode { + [pbr::OriginalName("ReturnNone")] ReturnNone = 0, + /// + ///成功 + /// + [pbr::OriginalName("Success")] Success = 1, + /// + ///失败 + /// + [pbr::OriginalName("Fail")] Fail = 2, + /// + ///消息超时 + /// + [pbr::OriginalName("MsgTimeOut")] MsgTimeOut = 3, + } + + public enum GAMESTATE { + [pbr::OriginalName("STATE1")] State1 = 0, + [pbr::OriginalName("STATE2")] State2 = 1, + [pbr::OriginalName("STATE3")] State3 = 2, + [pbr::OriginalName("STATE4")] State4 = 3, + } + + public enum CardType { + [pbr::OriginalName("NONE")] None = 0, + /// + ///草花 + /// + [pbr::OriginalName("CLUB")] Club = 1, + /// + ///方块 + /// + [pbr::OriginalName("DIAMOND")] Diamond = 2, + /// + ///红心 + /// + [pbr::OriginalName("HEART")] Heart = 3, + /// + ///黑桃 + /// + [pbr::OriginalName("SPADE")] Spade = 4, + /// + /// + [pbr::OriginalName("JOKER")] Joker = 5, + } + + #endregion + + #region Messages + public sealed partial class MainPack : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new MainPack()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::TEngineProto.TEngineProtoReflection.Descriptor.MessageTypes[0]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public MainPack() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public MainPack(MainPack other) : this() { + requestcode_ = other.requestcode_; + actioncode_ = other.actioncode_; + returncode_ = other.returncode_; + loginPack_ = other.loginPack_ != null ? other.loginPack_.Clone() : null; + extstr_ = other.extstr_; + roompack_ = other.roompack_.Clone(); + playerpack_ = other.playerpack_ != null ? other.playerpack_.Clone() : null; + heatEchoTime_ = other.heatEchoTime_; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public MainPack Clone() { + return new MainPack(this); + } + + /// Field number for the "requestcode" field. + public const int RequestcodeFieldNumber = 1; + private global::TEngineProto.RequestCode requestcode_ = global::TEngineProto.RequestCode.RequestNone; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public global::TEngineProto.RequestCode Requestcode { + get { return requestcode_; } + set { + requestcode_ = value; + } + } + + /// Field number for the "actioncode" field. + public const int ActioncodeFieldNumber = 2; + private global::TEngineProto.ActionCode actioncode_ = global::TEngineProto.ActionCode.ActionNone; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public global::TEngineProto.ActionCode Actioncode { + get { return actioncode_; } + set { + actioncode_ = value; + } + } + + /// Field number for the "returncode" field. + public const int ReturncodeFieldNumber = 3; + private global::TEngineProto.ReturnCode returncode_ = global::TEngineProto.ReturnCode.ReturnNone; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public global::TEngineProto.ReturnCode Returncode { + get { return returncode_; } + set { + returncode_ = value; + } + } + + /// Field number for the "loginPack" field. + public const int LoginPackFieldNumber = 4; + private global::TEngineProto.LoginPack loginPack_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public global::TEngineProto.LoginPack LoginPack { + get { return loginPack_; } + set { + loginPack_ = value; + } + } + + /// Field number for the "extstr" field. + public const int ExtstrFieldNumber = 5; + private string extstr_ = ""; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string Extstr { + get { return extstr_; } + set { + extstr_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + /// Field number for the "roompack" field. + public const int RoompackFieldNumber = 6; + private static readonly pb::FieldCodec _repeated_roompack_codec + = pb::FieldCodec.ForMessage(50, global::TEngineProto.RoomPack.Parser); + private readonly pbc::RepeatedField roompack_ = new pbc::RepeatedField(); + /// + ///房间包,repeated加上为list + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::RepeatedField Roompack { + get { return roompack_; } + } + + /// Field number for the "playerpack" field. + public const int PlayerpackFieldNumber = 7; + private global::TEngineProto.PlayerPack playerpack_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public global::TEngineProto.PlayerPack Playerpack { + get { return playerpack_; } + set { + playerpack_ = value; + } + } + + /// Field number for the "HeatEchoTime" field. + public const int HeatEchoTimeFieldNumber = 8; + private float heatEchoTime_; + /// + ///心跳包回包时间 + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public float HeatEchoTime { + get { return heatEchoTime_; } + set { + heatEchoTime_ = value; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as MainPack); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(MainPack other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Requestcode != other.Requestcode) return false; + if (Actioncode != other.Actioncode) return false; + if (Returncode != other.Returncode) return false; + if (!object.Equals(LoginPack, other.LoginPack)) return false; + if (Extstr != other.Extstr) return false; + if(!roompack_.Equals(other.roompack_)) return false; + if (!object.Equals(Playerpack, other.Playerpack)) return false; + if (!pbc::ProtobufEqualityComparers.BitwiseSingleEqualityComparer.Equals(HeatEchoTime, other.HeatEchoTime)) return false; + return Equals(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (Requestcode != global::TEngineProto.RequestCode.RequestNone) hash ^= Requestcode.GetHashCode(); + if (Actioncode != global::TEngineProto.ActionCode.ActionNone) hash ^= Actioncode.GetHashCode(); + if (Returncode != global::TEngineProto.ReturnCode.ReturnNone) hash ^= Returncode.GetHashCode(); + if (loginPack_ != null) hash ^= LoginPack.GetHashCode(); + if (Extstr.Length != 0) hash ^= Extstr.GetHashCode(); + hash ^= roompack_.GetHashCode(); + if (playerpack_ != null) hash ^= Playerpack.GetHashCode(); + if (HeatEchoTime != 0F) hash ^= pbc::ProtobufEqualityComparers.BitwiseSingleEqualityComparer.GetHashCode(HeatEchoTime); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (Requestcode != global::TEngineProto.RequestCode.RequestNone) { + output.WriteRawTag(8); + output.WriteEnum((int) Requestcode); + } + if (Actioncode != global::TEngineProto.ActionCode.ActionNone) { + output.WriteRawTag(16); + output.WriteEnum((int) Actioncode); + } + if (Returncode != global::TEngineProto.ReturnCode.ReturnNone) { + output.WriteRawTag(24); + output.WriteEnum((int) Returncode); + } + if (loginPack_ != null) { + output.WriteRawTag(34); + output.WriteMessage(LoginPack); + } + if (Extstr.Length != 0) { + output.WriteRawTag(42); + output.WriteString(Extstr); + } + roompack_.WriteTo(output, _repeated_roompack_codec); + if (playerpack_ != null) { + output.WriteRawTag(58); + output.WriteMessage(Playerpack); + } + if (HeatEchoTime != 0F) { + output.WriteRawTag(69); + output.WriteFloat(HeatEchoTime); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (Requestcode != global::TEngineProto.RequestCode.RequestNone) { + size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) Requestcode); + } + if (Actioncode != global::TEngineProto.ActionCode.ActionNone) { + size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) Actioncode); + } + if (Returncode != global::TEngineProto.ReturnCode.ReturnNone) { + size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) Returncode); + } + if (loginPack_ != null) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(LoginPack); + } + if (Extstr.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(Extstr); + } + size += roompack_.CalculateSize(_repeated_roompack_codec); + if (playerpack_ != null) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(Playerpack); + } + if (HeatEchoTime != 0F) { + size += 1 + 4; + } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(MainPack other) { + if (other == null) { + return; + } + if (other.Requestcode != global::TEngineProto.RequestCode.RequestNone) { + Requestcode = other.Requestcode; + } + if (other.Actioncode != global::TEngineProto.ActionCode.ActionNone) { + Actioncode = other.Actioncode; + } + if (other.Returncode != global::TEngineProto.ReturnCode.ReturnNone) { + Returncode = other.Returncode; + } + if (other.loginPack_ != null) { + if (loginPack_ == null) { + LoginPack = new global::TEngineProto.LoginPack(); + } + LoginPack.MergeFrom(other.LoginPack); + } + if (other.Extstr.Length != 0) { + Extstr = other.Extstr; + } + roompack_.Add(other.roompack_); + if (other.playerpack_ != null) { + if (playerpack_ == null) { + Playerpack = new global::TEngineProto.PlayerPack(); + } + Playerpack.MergeFrom(other.Playerpack); + } + if (other.HeatEchoTime != 0F) { + HeatEchoTime = other.HeatEchoTime; + } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + case 8: { + Requestcode = (global::TEngineProto.RequestCode) input.ReadEnum(); + break; + } + case 16: { + Actioncode = (global::TEngineProto.ActionCode) input.ReadEnum(); + break; + } + case 24: { + Returncode = (global::TEngineProto.ReturnCode) input.ReadEnum(); + break; + } + case 34: { + if (loginPack_ == null) { + LoginPack = new global::TEngineProto.LoginPack(); + } + input.ReadMessage(LoginPack); + break; + } + case 42: { + Extstr = input.ReadString(); + break; + } + case 50: { + roompack_.AddEntriesFrom(input, _repeated_roompack_codec); + break; + } + case 58: { + if (playerpack_ == null) { + Playerpack = new global::TEngineProto.PlayerPack(); + } + input.ReadMessage(Playerpack); + break; + } + case 69: { + HeatEchoTime = input.ReadFloat(); + break; + } + } + } + } + + } + + public sealed partial class LoginPack : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new LoginPack()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::TEngineProto.TEngineProtoReflection.Descriptor.MessageTypes[1]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public LoginPack() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public LoginPack(LoginPack other) : this() { + username_ = other.username_; + password_ = other.password_; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public LoginPack Clone() { + return new LoginPack(this); + } + + /// Field number for the "username" field. + public const int UsernameFieldNumber = 1; + private string username_ = ""; + /// + ///用户名 + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string Username { + get { return username_; } + set { + username_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + /// Field number for the "password" field. + public const int PasswordFieldNumber = 2; + private string password_ = ""; + /// + ///密码 + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string Password { + get { return password_; } + set { + password_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as LoginPack); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(LoginPack other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Username != other.Username) return false; + if (Password != other.Password) return false; + return Equals(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (Username.Length != 0) hash ^= Username.GetHashCode(); + if (Password.Length != 0) hash ^= Password.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (Username.Length != 0) { + output.WriteRawTag(10); + output.WriteString(Username); + } + if (Password.Length != 0) { + output.WriteRawTag(18); + output.WriteString(Password); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (Username.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(Username); + } + if (Password.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(Password); + } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(LoginPack other) { + if (other == null) { + return; + } + if (other.Username.Length != 0) { + Username = other.Username; + } + if (other.Password.Length != 0) { + Password = other.Password; + } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + case 10: { + Username = input.ReadString(); + break; + } + case 18: { + Password = input.ReadString(); + break; + } + } + } + } + + } + + public sealed partial class RoomPack : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new RoomPack()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::TEngineProto.TEngineProtoReflection.Descriptor.MessageTypes[2]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public RoomPack() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public RoomPack(RoomPack other) : this() { + roomname_ = other.roomname_; + maxnum_ = other.maxnum_; + curnum_ = other.curnum_; + state_ = other.state_; + gamestate_ = other.gamestate_ != null ? other.gamestate_.Clone() : null; + roomID_ = other.roomID_; + visable_ = other.visable_; + usePassword_ = other.usePassword_; + password_ = other.password_; + playerpack_ = other.playerpack_.Clone(); + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public RoomPack Clone() { + return new RoomPack(this); + } + + /// Field number for the "roomname" field. + public const int RoomnameFieldNumber = 1; + private string roomname_ = ""; + /// + ///房间名 + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string Roomname { + get { return roomname_; } + set { + roomname_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + /// Field number for the "maxnum" field. + public const int MaxnumFieldNumber = 2; + private int maxnum_; + /// + ///房间最大人数 + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int Maxnum { + get { return maxnum_; } + set { + maxnum_ = value; + } + } + + /// Field number for the "curnum" field. + public const int CurnumFieldNumber = 3; + private int curnum_; + /// + ///房间当前人数 + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int Curnum { + get { return curnum_; } + set { + curnum_ = value; + } + } + + /// Field number for the "state" field. + public const int StateFieldNumber = 4; + private int state_; + /// + ///房间状态 + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int State { + get { return state_; } + set { + state_ = value; + } + } + + /// Field number for the "gamestate" field. + public const int GamestateFieldNumber = 5; + private global::TEngineProto.GameStatePack gamestate_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public global::TEngineProto.GameStatePack Gamestate { + get { return gamestate_; } + set { + gamestate_ = value; + } + } + + /// Field number for the "roomID" field. + public const int RoomIDFieldNumber = 6; + private int roomID_; + /// + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int RoomID { + get { return roomID_; } + set { + roomID_ = value; + } + } + + /// Field number for the "visable" field. + public const int VisableFieldNumber = 9; + private int visable_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int Visable { + get { return visable_; } + set { + visable_ = value; + } + } + + /// Field number for the "usePassword" field. + public const int UsePasswordFieldNumber = 10; + private int usePassword_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int UsePassword { + get { return usePassword_; } + set { + usePassword_ = value; + } + } + + /// Field number for the "password" field. + public const int PasswordFieldNumber = 11; + private string password_ = ""; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string Password { + get { return password_; } + set { + password_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + /// Field number for the "playerpack" field. + public const int PlayerpackFieldNumber = 12; + private static readonly pb::FieldCodec _repeated_playerpack_codec + = pb::FieldCodec.ForMessage(98, global::TEngineProto.PlayerPack.Parser); + private readonly pbc::RepeatedField playerpack_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::RepeatedField Playerpack { + get { return playerpack_; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as RoomPack); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(RoomPack other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Roomname != other.Roomname) return false; + if (Maxnum != other.Maxnum) return false; + if (Curnum != other.Curnum) return false; + if (State != other.State) return false; + if (!object.Equals(Gamestate, other.Gamestate)) return false; + if (RoomID != other.RoomID) return false; + if (Visable != other.Visable) return false; + if (UsePassword != other.UsePassword) return false; + if (Password != other.Password) return false; + if(!playerpack_.Equals(other.playerpack_)) return false; + return Equals(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (Roomname.Length != 0) hash ^= Roomname.GetHashCode(); + if (Maxnum != 0) hash ^= Maxnum.GetHashCode(); + if (Curnum != 0) hash ^= Curnum.GetHashCode(); + if (State != 0) hash ^= State.GetHashCode(); + if (gamestate_ != null) hash ^= Gamestate.GetHashCode(); + if (RoomID != 0) hash ^= RoomID.GetHashCode(); + if (Visable != 0) hash ^= Visable.GetHashCode(); + if (UsePassword != 0) hash ^= UsePassword.GetHashCode(); + if (Password.Length != 0) hash ^= Password.GetHashCode(); + hash ^= playerpack_.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (Roomname.Length != 0) { + output.WriteRawTag(10); + output.WriteString(Roomname); + } + if (Maxnum != 0) { + output.WriteRawTag(16); + output.WriteInt32(Maxnum); + } + if (Curnum != 0) { + output.WriteRawTag(24); + output.WriteInt32(Curnum); + } + if (State != 0) { + output.WriteRawTag(32); + output.WriteInt32(State); + } + if (gamestate_ != null) { + output.WriteRawTag(42); + output.WriteMessage(Gamestate); + } + if (RoomID != 0) { + output.WriteRawTag(48); + output.WriteInt32(RoomID); + } + if (Visable != 0) { + output.WriteRawTag(72); + output.WriteInt32(Visable); + } + if (UsePassword != 0) { + output.WriteRawTag(80); + output.WriteInt32(UsePassword); + } + if (Password.Length != 0) { + output.WriteRawTag(90); + output.WriteString(Password); + } + playerpack_.WriteTo(output, _repeated_playerpack_codec); + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (Roomname.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(Roomname); + } + if (Maxnum != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(Maxnum); + } + if (Curnum != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(Curnum); + } + if (State != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(State); + } + if (gamestate_ != null) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(Gamestate); + } + if (RoomID != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(RoomID); + } + if (Visable != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(Visable); + } + if (UsePassword != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(UsePassword); + } + if (Password.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(Password); + } + size += playerpack_.CalculateSize(_repeated_playerpack_codec); + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(RoomPack other) { + if (other == null) { + return; + } + if (other.Roomname.Length != 0) { + Roomname = other.Roomname; + } + if (other.Maxnum != 0) { + Maxnum = other.Maxnum; + } + if (other.Curnum != 0) { + Curnum = other.Curnum; + } + if (other.State != 0) { + State = other.State; + } + if (other.gamestate_ != null) { + if (gamestate_ == null) { + Gamestate = new global::TEngineProto.GameStatePack(); + } + Gamestate.MergeFrom(other.Gamestate); + } + if (other.RoomID != 0) { + RoomID = other.RoomID; + } + if (other.Visable != 0) { + Visable = other.Visable; + } + if (other.UsePassword != 0) { + UsePassword = other.UsePassword; + } + if (other.Password.Length != 0) { + Password = other.Password; + } + playerpack_.Add(other.playerpack_); + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + case 10: { + Roomname = input.ReadString(); + break; + } + case 16: { + Maxnum = input.ReadInt32(); + break; + } + case 24: { + Curnum = input.ReadInt32(); + break; + } + case 32: { + State = input.ReadInt32(); + break; + } + case 42: { + if (gamestate_ == null) { + Gamestate = new global::TEngineProto.GameStatePack(); + } + input.ReadMessage(Gamestate); + break; + } + case 48: { + RoomID = input.ReadInt32(); + break; + } + case 72: { + Visable = input.ReadInt32(); + break; + } + case 80: { + UsePassword = input.ReadInt32(); + break; + } + case 90: { + Password = input.ReadString(); + break; + } + case 98: { + playerpack_.AddEntriesFrom(input, _repeated_playerpack_codec); + break; + } + } + } + } + + } + + public sealed partial class PlayerPack : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new PlayerPack()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::TEngineProto.TEngineProtoReflection.Descriptor.MessageTypes[3]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public PlayerPack() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public PlayerPack(PlayerPack other) : this() { + playername_ = other.playername_; + playerID_ = other.playerID_; + hp_ = other.hp_; + posPack_ = other.posPack_ != null ? other.posPack_.Clone() : null; + playerJob_ = other.playerJob_; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public PlayerPack Clone() { + return new PlayerPack(this); + } + + /// Field number for the "playername" field. + public const int PlayernameFieldNumber = 1; + private string playername_ = ""; + /// + ///玩家名称 + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string Playername { + get { return playername_; } + set { + playername_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + /// Field number for the "playerID" field. + public const int PlayerIDFieldNumber = 2; + private string playerID_ = ""; + /// + ///玩家ID + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string PlayerID { + get { return playerID_; } + set { + playerID_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + /// Field number for the "hp" field. + public const int HpFieldNumber = 3; + private int hp_; + /// + ///玩家血量 + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int Hp { + get { return hp_; } + set { + hp_ = value; + } + } + + /// Field number for the "posPack" field. + public const int PosPackFieldNumber = 4; + private global::TEngineProto.PosPack posPack_; + /// + ///位置信息 + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public global::TEngineProto.PosPack PosPack { + get { return posPack_; } + set { + posPack_ = value; + } + } + + /// Field number for the "playerJob" field. + public const int PlayerJobFieldNumber = 5; + private int playerJob_; + /// + ///玩家职业 + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int PlayerJob { + get { return playerJob_; } + set { + playerJob_ = value; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as PlayerPack); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(PlayerPack other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Playername != other.Playername) return false; + if (PlayerID != other.PlayerID) return false; + if (Hp != other.Hp) return false; + if (!object.Equals(PosPack, other.PosPack)) return false; + if (PlayerJob != other.PlayerJob) return false; + return Equals(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (Playername.Length != 0) hash ^= Playername.GetHashCode(); + if (PlayerID.Length != 0) hash ^= PlayerID.GetHashCode(); + if (Hp != 0) hash ^= Hp.GetHashCode(); + if (posPack_ != null) hash ^= PosPack.GetHashCode(); + if (PlayerJob != 0) hash ^= PlayerJob.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (Playername.Length != 0) { + output.WriteRawTag(10); + output.WriteString(Playername); + } + if (PlayerID.Length != 0) { + output.WriteRawTag(18); + output.WriteString(PlayerID); + } + if (Hp != 0) { + output.WriteRawTag(24); + output.WriteInt32(Hp); + } + if (posPack_ != null) { + output.WriteRawTag(34); + output.WriteMessage(PosPack); + } + if (PlayerJob != 0) { + output.WriteRawTag(40); + output.WriteInt32(PlayerJob); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (Playername.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(Playername); + } + if (PlayerID.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(PlayerID); + } + if (Hp != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(Hp); + } + if (posPack_ != null) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(PosPack); + } + if (PlayerJob != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(PlayerJob); + } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(PlayerPack other) { + if (other == null) { + return; + } + if (other.Playername.Length != 0) { + Playername = other.Playername; + } + if (other.PlayerID.Length != 0) { + PlayerID = other.PlayerID; + } + if (other.Hp != 0) { + Hp = other.Hp; + } + if (other.posPack_ != null) { + if (posPack_ == null) { + PosPack = new global::TEngineProto.PosPack(); + } + PosPack.MergeFrom(other.PosPack); + } + if (other.PlayerJob != 0) { + PlayerJob = other.PlayerJob; + } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + case 10: { + Playername = input.ReadString(); + break; + } + case 18: { + PlayerID = input.ReadString(); + break; + } + case 24: { + Hp = input.ReadInt32(); + break; + } + case 34: { + if (posPack_ == null) { + PosPack = new global::TEngineProto.PosPack(); + } + input.ReadMessage(PosPack); + break; + } + case 40: { + PlayerJob = input.ReadInt32(); + break; + } + } + } + } + + } + + public sealed partial class GameStatePack : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new GameStatePack()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::TEngineProto.TEngineProtoReflection.Descriptor.MessageTypes[4]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public GameStatePack() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public GameStatePack(GameStatePack other) : this() { + state_ = other.state_; + bossId_ = other.bossId_; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public GameStatePack Clone() { + return new GameStatePack(this); + } + + /// Field number for the "state" field. + public const int StateFieldNumber = 1; + private global::TEngineProto.GAMESTATE state_ = global::TEngineProto.GAMESTATE.State1; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public global::TEngineProto.GAMESTATE State { + get { return state_; } + set { + state_ = value; + } + } + + /// Field number for the "BossId" field. + public const int BossIdFieldNumber = 2; + private int bossId_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int BossId { + get { return bossId_; } + set { + bossId_ = value; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as GameStatePack); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(GameStatePack other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (State != other.State) return false; + if (BossId != other.BossId) return false; + return Equals(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (State != global::TEngineProto.GAMESTATE.State1) hash ^= State.GetHashCode(); + if (BossId != 0) hash ^= BossId.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (State != global::TEngineProto.GAMESTATE.State1) { + output.WriteRawTag(8); + output.WriteEnum((int) State); + } + if (BossId != 0) { + output.WriteRawTag(16); + output.WriteInt32(BossId); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (State != global::TEngineProto.GAMESTATE.State1) { + size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) State); + } + if (BossId != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(BossId); + } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(GameStatePack other) { + if (other == null) { + return; + } + if (other.State != global::TEngineProto.GAMESTATE.State1) { + State = other.State; + } + if (other.BossId != 0) { + BossId = other.BossId; + } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + case 8: { + State = (global::TEngineProto.GAMESTATE) input.ReadEnum(); + break; + } + case 16: { + BossId = input.ReadInt32(); + break; + } + } + } + } + + } + + public sealed partial class CardData : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new CardData()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::TEngineProto.TEngineProtoReflection.Descriptor.MessageTypes[5]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public CardData() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public CardData(CardData other) : this() { + cardInt_ = other.cardInt_; + cardValue_ = other.cardValue_; + cardType_ = other.cardType_; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public CardData Clone() { + return new CardData(this); + } + + /// Field number for the "cardInt" field. + public const int CardIntFieldNumber = 1; + private int cardInt_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CardInt { + get { return cardInt_; } + set { + cardInt_ = value; + } + } + + /// Field number for the "cardValue" field. + public const int CardValueFieldNumber = 2; + private int cardValue_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CardValue { + get { return cardValue_; } + set { + cardValue_ = value; + } + } + + /// Field number for the "cardType" field. + public const int CardTypeFieldNumber = 3; + private global::TEngineProto.CardType cardType_ = global::TEngineProto.CardType.None; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public global::TEngineProto.CardType CardType { + get { return cardType_; } + set { + cardType_ = value; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as CardData); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(CardData other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (CardInt != other.CardInt) return false; + if (CardValue != other.CardValue) return false; + if (CardType != other.CardType) return false; + return Equals(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (CardInt != 0) hash ^= CardInt.GetHashCode(); + if (CardValue != 0) hash ^= CardValue.GetHashCode(); + if (CardType != global::TEngineProto.CardType.None) hash ^= CardType.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (CardInt != 0) { + output.WriteRawTag(8); + output.WriteInt32(CardInt); + } + if (CardValue != 0) { + output.WriteRawTag(16); + output.WriteInt32(CardValue); + } + if (CardType != global::TEngineProto.CardType.None) { + output.WriteRawTag(24); + output.WriteEnum((int) CardType); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (CardInt != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(CardInt); + } + if (CardValue != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(CardValue); + } + if (CardType != global::TEngineProto.CardType.None) { + size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) CardType); + } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(CardData other) { + if (other == null) { + return; + } + if (other.CardInt != 0) { + CardInt = other.CardInt; + } + if (other.CardValue != 0) { + CardValue = other.CardValue; + } + if (other.CardType != global::TEngineProto.CardType.None) { + CardType = other.CardType; + } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + case 8: { + CardInt = input.ReadInt32(); + break; + } + case 16: { + CardValue = input.ReadInt32(); + break; + } + case 24: { + CardType = (global::TEngineProto.CardType) input.ReadEnum(); + break; + } + } + } + } + + } + + public sealed partial class PosPack : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new PosPack()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::TEngineProto.TEngineProtoReflection.Descriptor.MessageTypes[6]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public PosPack() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public PosPack(PosPack other) : this() { + posX_ = other.posX_; + posY_ = other.posY_; + posZ_ = other.posZ_; + rotaX_ = other.rotaX_; + rotaY_ = other.rotaY_; + rotaZ_ = other.rotaZ_; + animation_ = other.animation_; + dirr_ = other.dirr_; + moveX_ = other.moveX_; + moveY_ = other.moveY_; + moveZ_ = other.moveZ_; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public PosPack Clone() { + return new PosPack(this); + } + + /// Field number for the "PosX" field. + public const int PosXFieldNumber = 1; + private float posX_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public float PosX { + get { return posX_; } + set { + posX_ = value; + } + } + + /// Field number for the "PosY" field. + public const int PosYFieldNumber = 2; + private float posY_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public float PosY { + get { return posY_; } + set { + posY_ = value; + } + } + + /// Field number for the "PosZ" field. + public const int PosZFieldNumber = 3; + private float posZ_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public float PosZ { + get { return posZ_; } + set { + posZ_ = value; + } + } + + /// Field number for the "RotaX" field. + public const int RotaXFieldNumber = 4; + private float rotaX_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public float RotaX { + get { return rotaX_; } + set { + rotaX_ = value; + } + } + + /// Field number for the "RotaY" field. + public const int RotaYFieldNumber = 5; + private float rotaY_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public float RotaY { + get { return rotaY_; } + set { + rotaY_ = value; + } + } + + /// Field number for the "RotaZ" field. + public const int RotaZFieldNumber = 6; + private float rotaZ_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public float RotaZ { + get { return rotaZ_; } + set { + rotaZ_ = value; + } + } + + /// Field number for the "Animation" field. + public const int AnimationFieldNumber = 8; + private int animation_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int Animation { + get { return animation_; } + set { + animation_ = value; + } + } + + /// Field number for the "Dirr" field. + public const int DirrFieldNumber = 9; + private int dirr_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int Dirr { + get { return dirr_; } + set { + dirr_ = value; + } + } + + /// Field number for the "MoveX" field. + public const int MoveXFieldNumber = 10; + private float moveX_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public float MoveX { + get { return moveX_; } + set { + moveX_ = value; + } + } + + /// Field number for the "MoveY" field. + public const int MoveYFieldNumber = 11; + private float moveY_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public float MoveY { + get { return moveY_; } + set { + moveY_ = value; + } + } + + /// Field number for the "MoveZ" field. + public const int MoveZFieldNumber = 12; + private float moveZ_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public float MoveZ { + get { return moveZ_; } + set { + moveZ_ = value; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as PosPack); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(PosPack other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (!pbc::ProtobufEqualityComparers.BitwiseSingleEqualityComparer.Equals(PosX, other.PosX)) return false; + if (!pbc::ProtobufEqualityComparers.BitwiseSingleEqualityComparer.Equals(PosY, other.PosY)) return false; + if (!pbc::ProtobufEqualityComparers.BitwiseSingleEqualityComparer.Equals(PosZ, other.PosZ)) return false; + if (!pbc::ProtobufEqualityComparers.BitwiseSingleEqualityComparer.Equals(RotaX, other.RotaX)) return false; + if (!pbc::ProtobufEqualityComparers.BitwiseSingleEqualityComparer.Equals(RotaY, other.RotaY)) return false; + if (!pbc::ProtobufEqualityComparers.BitwiseSingleEqualityComparer.Equals(RotaZ, other.RotaZ)) return false; + if (Animation != other.Animation) return false; + if (Dirr != other.Dirr) return false; + if (!pbc::ProtobufEqualityComparers.BitwiseSingleEqualityComparer.Equals(MoveX, other.MoveX)) return false; + if (!pbc::ProtobufEqualityComparers.BitwiseSingleEqualityComparer.Equals(MoveY, other.MoveY)) return false; + if (!pbc::ProtobufEqualityComparers.BitwiseSingleEqualityComparer.Equals(MoveZ, other.MoveZ)) return false; + return Equals(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (PosX != 0F) hash ^= pbc::ProtobufEqualityComparers.BitwiseSingleEqualityComparer.GetHashCode(PosX); + if (PosY != 0F) hash ^= pbc::ProtobufEqualityComparers.BitwiseSingleEqualityComparer.GetHashCode(PosY); + if (PosZ != 0F) hash ^= pbc::ProtobufEqualityComparers.BitwiseSingleEqualityComparer.GetHashCode(PosZ); + if (RotaX != 0F) hash ^= pbc::ProtobufEqualityComparers.BitwiseSingleEqualityComparer.GetHashCode(RotaX); + if (RotaY != 0F) hash ^= pbc::ProtobufEqualityComparers.BitwiseSingleEqualityComparer.GetHashCode(RotaY); + if (RotaZ != 0F) hash ^= pbc::ProtobufEqualityComparers.BitwiseSingleEqualityComparer.GetHashCode(RotaZ); + if (Animation != 0) hash ^= Animation.GetHashCode(); + if (Dirr != 0) hash ^= Dirr.GetHashCode(); + if (MoveX != 0F) hash ^= pbc::ProtobufEqualityComparers.BitwiseSingleEqualityComparer.GetHashCode(MoveX); + if (MoveY != 0F) hash ^= pbc::ProtobufEqualityComparers.BitwiseSingleEqualityComparer.GetHashCode(MoveY); + if (MoveZ != 0F) hash ^= pbc::ProtobufEqualityComparers.BitwiseSingleEqualityComparer.GetHashCode(MoveZ); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (PosX != 0F) { + output.WriteRawTag(13); + output.WriteFloat(PosX); + } + if (PosY != 0F) { + output.WriteRawTag(21); + output.WriteFloat(PosY); + } + if (PosZ != 0F) { + output.WriteRawTag(29); + output.WriteFloat(PosZ); + } + if (RotaX != 0F) { + output.WriteRawTag(37); + output.WriteFloat(RotaX); + } + if (RotaY != 0F) { + output.WriteRawTag(45); + output.WriteFloat(RotaY); + } + if (RotaZ != 0F) { + output.WriteRawTag(53); + output.WriteFloat(RotaZ); + } + if (Animation != 0) { + output.WriteRawTag(64); + output.WriteInt32(Animation); + } + if (Dirr != 0) { + output.WriteRawTag(72); + output.WriteInt32(Dirr); + } + if (MoveX != 0F) { + output.WriteRawTag(85); + output.WriteFloat(MoveX); + } + if (MoveY != 0F) { + output.WriteRawTag(93); + output.WriteFloat(MoveY); + } + if (MoveZ != 0F) { + output.WriteRawTag(101); + output.WriteFloat(MoveZ); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (PosX != 0F) { + size += 1 + 4; + } + if (PosY != 0F) { + size += 1 + 4; + } + if (PosZ != 0F) { + size += 1 + 4; + } + if (RotaX != 0F) { + size += 1 + 4; + } + if (RotaY != 0F) { + size += 1 + 4; + } + if (RotaZ != 0F) { + size += 1 + 4; + } + if (Animation != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(Animation); + } + if (Dirr != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(Dirr); + } + if (MoveX != 0F) { + size += 1 + 4; + } + if (MoveY != 0F) { + size += 1 + 4; + } + if (MoveZ != 0F) { + size += 1 + 4; + } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(PosPack other) { + if (other == null) { + return; + } + if (other.PosX != 0F) { + PosX = other.PosX; + } + if (other.PosY != 0F) { + PosY = other.PosY; + } + if (other.PosZ != 0F) { + PosZ = other.PosZ; + } + if (other.RotaX != 0F) { + RotaX = other.RotaX; + } + if (other.RotaY != 0F) { + RotaY = other.RotaY; + } + if (other.RotaZ != 0F) { + RotaZ = other.RotaZ; + } + if (other.Animation != 0) { + Animation = other.Animation; + } + if (other.Dirr != 0) { + Dirr = other.Dirr; + } + if (other.MoveX != 0F) { + MoveX = other.MoveX; + } + if (other.MoveY != 0F) { + MoveY = other.MoveY; + } + if (other.MoveZ != 0F) { + MoveZ = other.MoveZ; + } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + case 13: { + PosX = input.ReadFloat(); + break; + } + case 21: { + PosY = input.ReadFloat(); + break; + } + case 29: { + PosZ = input.ReadFloat(); + break; + } + case 37: { + RotaX = input.ReadFloat(); + break; + } + case 45: { + RotaY = input.ReadFloat(); + break; + } + case 53: { + RotaZ = input.ReadFloat(); + break; + } + case 64: { + Animation = input.ReadInt32(); + break; + } + case 72: { + Dirr = input.ReadInt32(); + break; + } + case 85: { + MoveX = input.ReadFloat(); + break; + } + case 93: { + MoveY = input.ReadFloat(); + break; + } + case 101: { + MoveZ = input.ReadFloat(); + break; + } + } + } + } + + } + + #endregion + +} + +#endregion Designer generated code diff --git a/TEngineHotUpdate/src/TEngineCore/Core/GameTime.cs b/TEngineHotUpdate/src/TEngineCore/Core/GameTime.cs new file mode 100644 index 00000000..3c3eda80 --- /dev/null +++ b/TEngineHotUpdate/src/TEngineCore/Core/GameTime.cs @@ -0,0 +1,31 @@ +using UnityEngine; + +namespace TEngineCore +{ + public static class GameTime + { + public static void StartFrame() + { + time = Time.time; + deltaTime = Time.deltaTime; + quickRealTime = Time.realtimeSinceStartup; + frameCount = Time.frameCount; + unscaledTime = Time.unscaledTime; + } + + public static float time; + public static float deltaTime; + public static int frameCount; + public static float unscaledTime; + + public static float realtimeSinceStartup + { + get + { + return Time.realtimeSinceStartup; + } + } + + public static float quickRealTime; + } +} \ No newline at end of file diff --git a/TEngineHotUpdate/src/TEngineCore/Net/ClientConnectWatcher.cs b/TEngineHotUpdate/src/TEngineCore/Net/ClientConnectWatcher.cs new file mode 100644 index 00000000..24ae8d32 --- /dev/null +++ b/TEngineHotUpdate/src/TEngineCore/Net/ClientConnectWatcher.cs @@ -0,0 +1,166 @@ +namespace TEngineCore.Net +{ + enum ClientConnectWatcherStatus + { + StatusInit, + StatusReconnectAuto, + StatusReconnectConfirm, + StatusWaitExit + } + + class ClientConnectWatcher + { + #region Propreties + private GameClient m_client; + private float m_statusTime; + private int m_reconnetCnt = 0; + private int m_disconnectReason = 0; + private ClientConnectWatcherStatus m_status = ClientConnectWatcherStatus.StatusInit; + + private bool m_enable = false; + public bool Enable + { + get { return m_enable; } + set + { + if (m_enable != value) + { + m_enable = value; + if (m_enable) + { + OnEnable(); + } + else + { + OnDisable(); + } + } + } + } + + ClientConnectWatcherStatus Status + { + get { return m_status; } + set + { + if (m_status != value) + { + m_status = value; + m_statusTime = GameTime.time; + } + } + } + #endregion + + public ClientConnectWatcher(GameClient client) + { + m_client = client; + m_statusTime = GameTime.time; + m_status = ClientConnectWatcherStatus.StatusInit; + } + + public void Update() + { + if (!m_enable) + { + return; + } + + if (m_client.IsEntered) + { + return; + } + + switch (m_status) + { + case ClientConnectWatcherStatus.StatusInit: + UpdateOnInitStatus(); + break; + case ClientConnectWatcherStatus.StatusReconnectAuto: + UpdateOnReconnectAuto(); + break; + case ClientConnectWatcherStatus.StatusReconnectConfirm: + UpdateOnReconnectConfirm(); + break; + case ClientConnectWatcherStatus.StatusWaitExit: + UpdateOnWaitExit(); + break; + + default: + break; + } + } + + public void OnReConnect() + { + if (m_status == ClientConnectWatcherStatus.StatusReconnectConfirm) + { + Status = ClientConnectWatcherStatus.StatusReconnectAuto; + } + } + + void UpdateOnInitStatus() + { + if (m_reconnetCnt <= 2) + { + if (m_reconnetCnt == 0) + { + m_disconnectReason = m_client.LastNetErrCode; + } + + Status = ClientConnectWatcherStatus.StatusReconnectAuto; + m_reconnetCnt++; + + //Reconnect + m_client.Reconnect(); + } + else + { + Status = ClientConnectWatcherStatus.StatusReconnectConfirm; + m_reconnetCnt++; + + //var window = UISys.Mgr.ShowWindow(); + //window.SetErrCode(m_disconnectReason); + } + } + + void UpdateOnReconnectAuto() + { + if (m_client.IsEntered) + { + Status = ClientConnectWatcherStatus.StatusInit; + m_reconnetCnt = 0; + return; + } + + float nowTime = GameTime.time; + if (m_statusTime + 5 < nowTime) + { + //切换到默认的,下一帧继续判断是否需要自动还是手动 + Status = ClientConnectWatcherStatus.StatusInit; + return; + } + } + + void UpdateOnReconnectConfirm() + { + + } + + void UpdateOnWaitExit() + { + } + + private void OnDisable() + { + Status = ClientConnectWatcherStatus.StatusInit; + m_reconnetCnt = 0; + } + + private void OnEnable() + { + Status = ClientConnectWatcherStatus.StatusInit; + m_reconnetCnt = 0; + } + } +} diff --git a/TEngineHotUpdate/src/TEngineCore/Net/ClientSocket/IClientSocket.cs b/TEngineHotUpdate/src/TEngineCore/Net/ClientSocket/IClientSocket.cs new file mode 100644 index 00000000..7e349819 --- /dev/null +++ b/TEngineHotUpdate/src/TEngineCore/Net/ClientSocket/IClientSocket.cs @@ -0,0 +1,118 @@ +using System; +using System.Net; +using System.Net.Sockets; + +namespace TEngineCore.Net +{ + public enum ClientSocketEventType + { + EventConnected, + EventConnectFail, + EventDisconnected, + } + + public interface IClientSocket + { + /// + /// 是否连接了 + /// + bool IsConnected { get; } + + /// + /// 是否是流协议 + /// + bool IsStream { get; } + + /// + /// 心跳间隔 + /// + int HeartBeatInterval { get; } + + /// + /// 本地绑定地址 + /// + EndPoint LocalAddr { get; } + + SocketError LastSockError { get; } + + string LastErrDesc { get; } + + /// + /// 注册系统事件 + /// + /// + void RegEventHandle(Action handler); + + /// + /// 连接请求 + /// + /// + /// + /// + /// + /// + bool Connect(string server, int port, int iTimeout, int retryNum); + + /// + /// 关闭连接 + /// + void Close(); + + /// + /// 关闭连接 + /// + void Shutdown(); + + /// + /// 发送数据 + /// + /// + bool Send(byte[] data, int offset, int len); + + /// + /// 发送快捷数据,不用保证丢包 + /// + /// + /// + /// + /// + bool SendUdpTypeData(byte[] data, int offset, int len); + + /// + /// 是否支持udp的包 + /// + /// + bool IsSupportUdpType(); + + /// + /// 收包处理 + /// + /// + /// + /// + /// + int Recv(byte[] buf, int iOffset, int maxSize); + + /// + /// 循环调用 + /// + void Update(); + + /// + /// 最后一帧,保证肯定要包发出去,减少延迟 + /// + void LateUpdate(); + + /// + /// 获取写队列的个数 + /// + /// + int GetSendQueueCount(); + + /// + /// 像底层注册错误打印,当缓冲区满之类的,调用上层的统计来打印 + /// + /// + void RegDebugCmdHandle(Action debugCmd); + } +} diff --git a/TEngineHotUpdate/src/TEngineCore/Net/ClientSocket/Message.cs b/TEngineHotUpdate/src/TEngineCore/Net/ClientSocket/Message.cs new file mode 100644 index 00000000..8bbe625e --- /dev/null +++ b/TEngineHotUpdate/src/TEngineCore/Net/ClientSocket/Message.cs @@ -0,0 +1,117 @@ + +using System; +using System.Linq; +using Google.Protobuf; +using TEngineProto; + +namespace TEngineCore.Net +{ + public class Message + { + private const int BufferHead = 4; + + private static byte[] buffer = new byte[1024]; + + private int startindex; + + public byte[] Buffer + { + get { return buffer; } + } + + public int StartIndex + { + get { return startindex; } + } + + public int Remsize + { + get { return buffer.Length - startindex; } + } + + public void ReadBuffer(byte[] bufBytes, Action handleResponse = null) + { + var length = bufBytes.Length; + + for (int i = 0; i < length; i++) + { + Buffer[i] = bufBytes[i]; + } + + startindex += length; + + if (startindex <= BufferHead) + { + return; + } + + int count = length - BufferHead; + + while (true) + { + if (startindex >= (count + BufferHead)) + { + MainPack pack = (MainPack)MainPack.Descriptor.Parser.ParseFrom(buffer, BufferHead, count); + + if (handleResponse != null) + { + handleResponse(pack); + } + + Array.Copy(buffer, length, buffer, 0, startindex - length); + + startindex -= length; + } + else + { + break; + } + } + } + + public void ReadBuffer(int length, Action handleResponse = null) + { + startindex += length; + + if (startindex <= BufferHead) + { + return; + } + + int count = length - BufferHead; + + while (true) + { + if (startindex >= (count + BufferHead)) + { + MainPack pack = (MainPack)MainPack.Descriptor.Parser.ParseFrom(buffer, BufferHead, count); + + if (handleResponse != null) + { + handleResponse(pack); + } + + Array.Copy(buffer, length, buffer, 0, startindex - length); + + startindex -= length; + } + else + { + break; + } + } + } + + public static byte[] PackData(MainPack pack) + { + byte[] data = pack.ToByteArray(); + byte[] head = BitConverter.GetBytes(data.Length); + return head.Concat(data).ToArray(); + } + + public static byte[] PackDataUdp(MainPack pack) + { + return pack.ToByteArray(); + } + } +} \ No newline at end of file diff --git a/TEngineHotUpdate/src/TEngineCore/Net/ClientSocket/TcpConnection.cs b/TEngineHotUpdate/src/TEngineCore/Net/ClientSocket/TcpConnection.cs new file mode 100644 index 00000000..cc8093cc --- /dev/null +++ b/TEngineHotUpdate/src/TEngineCore/Net/ClientSocket/TcpConnection.cs @@ -0,0 +1,120 @@ +using System; +using System.Collections.Generic; +using System.Net.Sockets; +using TEngineProto; + + +namespace TEngineCore.Net +{ + public class TcpConnection + { + private Socket socket; + private string m_Host; + private int m_Port; + private Message message; + private GameClient gameClient; + + public TcpConnection(GameClient gameClient) + { + message = new Message(); + this.gameClient = gameClient; + } + + public bool Connect(string host, int port) + { + if (socket == null) + { + socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); + } + else + { + if (socket.Connected) + { + socket.Close(); + } + } + + TLogger.LogInfo("start connect server[{0}:{1}]...", host, port); + + gameClient.Status = GameClientStatus.StatusInit; + try + { + socket.Connect(host, port); + StartReceive(); + gameClient.Status = GameClientStatus.StatusConnect; + } + catch (Exception e) + { + TLogger.LogError(e.Message); + TLogger.LogError("socket connect {0}:{1} failed", host, port); + //ChangeStateOnEnterFail(); + return false; + } + m_Host = host; + m_Port = port; + return true; + } + + void StartReceive() + { + socket.BeginReceive(message.Buffer, message.StartIndex, message.Remsize, SocketFlags.None, ReceiveCallback, null); + } + + void ReceiveCallback(IAsyncResult asyncResult) + { + try + { + if (socket == null || socket.Connected == false) + { + return; + } + + int Length = socket.EndReceive(asyncResult); + + if (Length == 0) + { + Close(); + + return; + } + + message.ReadBuffer(Length, gameClient.HandleResponse); + + StartReceive(); + } + catch (Exception e) + { + TLogger.LogError("TcpConnection DisConnected: " + e); + Close(); + } + } + + public bool SendCsMsg(MainPack mainPack) + { + if (socket == null || socket.Connected == false) + { + return false; + } + + try + { + socket.Send(Message.PackData(mainPack)); + return true; + } + catch (Exception e) + { + TLogger.LogError("TcpConnection SendCsMsg: " + e); + return false; + } + } + + public void Close() + { + if (socket != null && socket.Connected) + { + socket.Close(); + } + gameClient.Status = GameClientStatus.StatusInit; + } + } +} diff --git a/TEngineHotUpdate/src/TEngineCore/Net/ClientSocket/UdpConnection.cs b/TEngineHotUpdate/src/TEngineCore/Net/ClientSocket/UdpConnection.cs new file mode 100644 index 00000000..31b6862e --- /dev/null +++ b/TEngineHotUpdate/src/TEngineCore/Net/ClientSocket/UdpConnection.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace TEngineCore.Net +{ + public class UdpConnection + { + + } +} diff --git a/TEngineHotUpdate/src/TEngineCore/Net/DataCenterSys.cs b/TEngineHotUpdate/src/TEngineCore/Net/DataCenterSys.cs new file mode 100644 index 00000000..480c4201 --- /dev/null +++ b/TEngineHotUpdate/src/TEngineCore/Net/DataCenterSys.cs @@ -0,0 +1,42 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace TEngineCore.Net +{ + /// + /// 数据中心系统 + /// + public class DataCenterSys : BaseLogicSys + { + private List m_listModule = new List(); + + public override bool OnInit() + { + RegCmdHandle(); + InitModule(); + return true; + } + + private void RegCmdHandle() + { + + } + + void InitModule() + { + //InitModule(LoginDataMgr.Instance); + } + + public void InitModule(IDataCenterModule module) + { + if (!m_listModule.Contains(module)) + { + module.Init(); + m_listModule.Add(module); + } + } + } +} diff --git a/TEngineHotUpdate/src/TEngineCore/Net/GameClient.cs b/TEngineHotUpdate/src/TEngineCore/Net/GameClient.cs new file mode 100644 index 00000000..ebf51daa --- /dev/null +++ b/TEngineHotUpdate/src/TEngineCore/Net/GameClient.cs @@ -0,0 +1,568 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using TEngineProto; +using UnityEngine; + +namespace TEngineCore.Net +{ + /// + /// 客户端状态 + /// + public enum GameClientStatus + { + StatusInit, //初始化 + StatusReconnect, //重新连接 + StatusClose, //断开连接 + StatusConnect, //连接中 + StatusEnter, //Login登录成功 + } + + public delegate void CsMsgDelegate(MainPack mainPack); + + public class GameClient:TSingleton + { + + #region Propriety + + #region TimeOutCheck + private const int CHECK_TIMEOUT_PERFRAME = 10; + const int MAX_MSG_HANDLE = 256; + UInt32 m_dwLastCheckIndex = 0; + CsMsgDelegate[] m_aMsgHandles = new CsMsgDelegate[MAX_MSG_HANDLE]; + float[] m_fMsgRegTime = new float[MAX_MSG_HANDLE]; + private float m_timeout = 15; + #endregion + + private string m_lastHost = null; + private int m_lastPort = 0; + private GameClientStatus m_status = GameClientStatus.StatusInit; + /// + /// GameClient状态 + /// + public GameClientStatus Status + { + get + { + return m_status; + } + set + { + m_status = value; + } + } + + /// + /// 最新连接错误的时间 + /// + private float m_lastLogDisconnectErrTime = 0f; + /// + /// 最新的错误码 + /// + private int m_lastNetErrCode = 0; + /// + /// 最近一次心跳的时间 + /// + private float m_lastHbTime = 0f; + /// + /// 心跳间隔 + /// + private const float m_heartBeatDurTime = 15; + /// + /// 连续心跳超时 + /// + private int m_heatBeatTimeoutNum = 0; + private int m_ping = -1; + public bool IsEntered + { + get { return m_status == GameClientStatus.StatusEnter; } + } + public bool IsNetworkOkAndLogined + { + get + { + return m_status == GameClientStatus.StatusEnter; + } + } + + public int LastNetErrCode + { + get { return m_lastNetErrCode; } + } + + private ClientConnectWatcher m_connectWatcher; + + private void ResetParam() + { + m_lastLogDisconnectErrTime = 0f; + m_heatBeatTimeoutNum = 0; + m_lastHbTime = 0f; + m_ping = -1; + m_lastNetErrCode = 0; + } + #endregion + + private TcpConnection m_connect; + + public GameClient() + { + m_connect = new TcpConnection(this); + m_connectWatcher = new ClientConnectWatcher(this); + } + + public bool Connect(string host, int port, bool reconnect = false) + { + ResetParam(); + if (!reconnect) + { + SetWatchReconnect(false); + } + //GameEventMgr.Instance.Send(ShowWaitingUI); + m_lastHost = host; + m_lastPort = port; + Status = reconnect ? GameClientStatus.StatusReconnect : GameClientStatus.StatusInit; + TLogger.LogWarning("Start connect server {0}:{1} Reconnect:{2}", host, port, reconnect); + return m_connect.Connect(host, port); + } + + public void Shutdown() + { + m_connect.Close(); + m_status = GameClientStatus.StatusInit; + } + + #region 发送网络消息 + /// + /// 发送消息包 + /// + /// + /// + public bool SendCsMsg(MainPack reqPkg) + { + if (!CheckPack(reqPkg)) + { + return false; + } + return DoSendData(reqPkg); + } + + /// + /// 发送消息包并注册回调 + /// + /// + /// + /// + /// + public bool SendCsMsg(MainPack pack, CsMsgDelegate resHandler = null, bool needShowWaitUI = true) + { + if (!CheckPack(pack)) + { + return false; + } + + var ret = DoSendData(pack); + + if (!ret) + { + TLogger.LogError("SendCSMsg Error"); + } + else + { + if (resHandler != null) + { + RegTimeOutHandle((uint)pack.Actioncode, resHandler); + RegActionHandle((int)pack.Actioncode, resHandler); + } + } + + return ret; + } + + private bool DoSendData(MainPack reqPkg) + { + var sendRet = m_connect.SendCsMsg(reqPkg); + + return sendRet; + } + #endregion + + #region 网络消息回调,非主线程 + Dictionary> m_mapCmdHandle = new Dictionary>(); + /// + /// 委托缓存堆栈 + /// + private Queue> cachelistHandle = new Queue>(); + + /// + /// 消息包缓存堆栈 + /// + private Queue queuepPacks = new Queue(); + + /// + /// 网络消息回调,非主线程 + /// + /// + public void HandleResponse(MainPack pack) + { + lock (cachelistHandle) + { + List listHandle; + + if (m_mapCmdHandle.TryGetValue((int)pack.Actioncode, out listHandle)) + { + cachelistHandle.Enqueue(listHandle); + + queuepPacks.Enqueue(pack); + } + } + } + /// + /// Udp网络消息回调,非主线程 + /// + /// + private void UdpHandleResponse(MainPack pack) + { + //Debug.Log(pack); + List listHandle; + + if (m_mapCmdHandle.TryGetValue((int)pack.Actioncode, out listHandle)) + { + foreach (CsMsgDelegate handle in listHandle) + { + handle(pack); + } + } + } + + + #endregion + + #region 注册网络消息回调 + /// + /// 注册静态消息 + /// + /// + /// + public void RegActionHandle(int actionId, CsMsgDelegate msgDelegate) + { + List listHandle; + if (!m_mapCmdHandle.TryGetValue(actionId, out listHandle)) + { + listHandle = new List(); + m_mapCmdHandle[actionId] = listHandle; + } + + if (listHandle != null) + { + if (listHandle.Contains(msgDelegate)) + { + Debug.LogFormat("-------------repeat RegCmdHandle ActionCode:{0}-----------", (ActionCode)actionId); + } + listHandle.Add(msgDelegate); + } + } + /// + /// 注册Udp静态消息 + /// + /// + /// + public void UdpRegActionHandle(int actionId, CsMsgDelegate msgDelegate) + { + List listHandle; + if (!m_mapCmdHandle.TryGetValue(actionId, out listHandle)) + { + listHandle = new List(); + m_mapCmdHandle[actionId] = listHandle; + } + + if (listHandle != null) + { + if (listHandle.Contains(msgDelegate)) + { + Debug.LogFormat("-------------repeat RegCmdHandle ActionCode:{0}-----------", (ActionCode)actionId); + } + listHandle.Add(msgDelegate); + } + } + + /// + /// 移除消息处理函数 + /// + /// + /// + public void RmvCmdHandle(int actionId, CsMsgDelegate msgDelegate) + { + List listHandle; + if (!m_mapCmdHandle.TryGetValue(actionId, out listHandle)) + { + return; + } + + if (listHandle != null) + { + listHandle.Remove(msgDelegate); + } + } + + private bool CheckPack(MainPack pack) + { + if (pack == null) + { + return false; + } + + if (pack.Actioncode == ActionCode.ActionNone) + { + return false; + } + + if (pack.Requestcode == RequestCode.RequestNone) + { + return false; + } + + return true; + } + #endregion + + #region 心跳处理 + protected bool CheckHeatBeatTimeout() + { + if (m_heatBeatTimeoutNum >= 2) + { + Shutdown(); + m_heatBeatTimeoutNum = 0; + Status = GameClientStatus.StatusClose; + TLogger.LogError("heat beat detect timeout"); + return false; + } + + return true; + } + + void TickHeartBeat() + { + if (Status != GameClientStatus.StatusEnter) + { + return; + } + + var nowTime = GameTime.realtimeSinceStartup; + if (m_lastHbTime + m_heartBeatDurTime < nowTime) + { + m_lastHbTime = nowTime; + MainPack pack = new MainPack + { + Actioncode = ActionCode.HeartBeat + }; + GameClient.Instance.SendCsMsg(pack, HandleHeatBeatRes); + } + } + + void HandleHeatBeatRes(MainPack mainPack) + { + if (mainPack.Returncode != ReturnCode.Success) + { + //如果是超时了,则标记最近收到包的次数 + if (mainPack.Returncode == ReturnCode.MsgTimeOut) + { + m_heatBeatTimeoutNum++; + TLogger.LogError("heat beat timeout: {0}", m_heatBeatTimeoutNum); + } + } + else + { + float diffTime = GameTime.realtimeSinceStartup - mainPack.HeatEchoTime; + m_ping = (int)(diffTime * 1000); + m_heatBeatTimeoutNum = 0; + } + } + #endregion + + /// + /// 清理所有的网络消息 + /// + public void CleanAllNetMsg() + { + m_mapCmdHandle.Clear(); + } + + public void Reconnect() + { + m_connectWatcher.OnReConnect(); + Connect(m_lastHost, m_lastPort, true); + } + + public void OnUpdate() + { + HandleCsMsgOnUpdate(); + CheckCsMsgTimeOut(); + TickHeartBeat(); + CheckHeatBeatTimeout(); + m_connectWatcher.Update(); + } + + #region 超时检测 + + private readonly MainPack _timeOutPack = new MainPack { Returncode = ReturnCode.MsgTimeOut }; + private void CheckCsMsgTimeOut() + { + float nowTime = GameTime.time; + for (int i = 0; i < CHECK_TIMEOUT_PERFRAME; i++) + { + m_dwLastCheckIndex = (m_dwLastCheckIndex + 1) % MAX_MSG_HANDLE; + if (m_aMsgHandles[m_dwLastCheckIndex] != null) + { + if (m_fMsgRegTime[m_dwLastCheckIndex] + m_timeout < nowTime) + { + TLogger.LogError("msg timeout, resCmdID[{0}]", m_aMsgHandles[m_dwLastCheckIndex]); + + NotifyTimeout(m_aMsgHandles[m_dwLastCheckIndex]); + + RmvCheckCsMsg((int)m_dwLastCheckIndex); + } + } + } + } + + public void RmvCheckCsMsg(int index) + { + m_aMsgHandles[index] = null; + m_fMsgRegTime[index] = 0; + } + + private void RegTimeOutHandle(uint actionCode, CsMsgDelegate resHandler) + { + uint hashIndex = actionCode % MAX_MSG_HANDLE; + m_aMsgHandles[hashIndex] = resHandler; + m_fMsgRegTime[hashIndex] = GameTime.time; + } + + protected void NotifyTimeout(CsMsgDelegate msgHandler) + { + msgHandler(_timeOutPack); + } + + #endregion + + private void HandleCsMsgOnUpdate() + { + if (cachelistHandle.Count <= 0 || queuepPacks.Count <= 0) + { + return; + } + try + { + foreach (CsMsgDelegate handle in cachelistHandle.Dequeue()) + { + handle(queuepPacks.Peek()); + } + queuepPacks.Dequeue(); + } + catch (Exception e) + { + TLogger.LogError(e.Message); + } + } + + protected override void Init() + { + base.Init(); + } + + public override void Active() + { + base.Active(); + } + + public override void Release() + { + base.Release(); + } + + public bool IsStatusCanSendMsg() + { + if (m_status == GameClientStatus.StatusEnter) + { + return true; + } + + float nowTime = GameTime.time; + if (m_lastLogDisconnectErrTime + 5 < nowTime) + { + TLogger.LogError("GameClient not connected, send msg failed"); + m_lastLogDisconnectErrTime = nowTime; + } + + return false; + } + + /// + /// 设置是否需要监控网络重连 + /// + /// + public void SetWatchReconnect(bool needWatch) + { + m_connectWatcher.Enable = needWatch; + } + + #region Ping + /// + /// ping值 + /// + public int Ping + { + get + { + if (IsPingValid()) + { + return m_ping / 4; + } + else + { + return 0; + } + } + } + + public bool IsPingValid() + { + if (IsNetworkOkAndLogined) + { + return m_ping >= 0; + } + return false; + } + #endregion + + #region GetNetworkType + public static CsNetworkType GetNetworkType() + { + CsNetworkType csNetType = CsNetworkType.CSNETWORK_UNKNOWN; + NetworkReachability reachability = Application.internetReachability; + switch (reachability) + { + case NetworkReachability.NotReachable: + break; + case NetworkReachability.ReachableViaLocalAreaNetwork: + csNetType = CsNetworkType.CSNETWORK_WIFI; + break; + case NetworkReachability.ReachableViaCarrierDataNetwork: + csNetType = CsNetworkType.CSNETWORK_3G; + break; + } + return csNetType; + } + + public enum CsNetworkType + { + CSNETWORK_UNKNOWN = 0, /*未知类型*/ + CSNETWORK_WIFI = 1, /*Wifi类型*/ + CSNETWORK_3G = 2, /*3G类型*/ + CSNETWORK_2G = 3 /*2G类型*/ + }; + #endregion + } +} diff --git a/TEngineHotUpdate/src/TEngineCore/Net/IDataCenterModule.cs b/TEngineHotUpdate/src/TEngineCore/Net/IDataCenterModule.cs new file mode 100644 index 00000000..6e4ca352 --- /dev/null +++ b/TEngineHotUpdate/src/TEngineCore/Net/IDataCenterModule.cs @@ -0,0 +1,48 @@ +namespace TEngineCore.Net +{ + public interface IDataCenterModule + { + void Init(); + + void OnRoleLogout(); + + void OnUpdate(); + + void OnMainPlayerMapChange(); + } + public class DataCenterModule : IDataCenterModule where T : new() + { + private static T instance; + public static T Instance + { + get + { + if (null == instance) + { + instance = new T(); + } + return instance; + } + } + + public virtual void Init() + { + + } + + public virtual void OnRoleLogout() + { + + } + + public virtual void OnUpdate() + { + + } + + public virtual void OnMainPlayerMapChange() + { + + } + } +} diff --git a/TEngineHotUpdate/src/TEngineCore/Net/NetEventId.cs b/TEngineHotUpdate/src/TEngineCore/Net/NetEventId.cs new file mode 100644 index 00000000..403fdb09 --- /dev/null +++ b/TEngineHotUpdate/src/TEngineCore/Net/NetEventId.cs @@ -0,0 +1,9 @@ +namespace TEngineCore.Net +{ + internal class NetEventId + { + public static int HeartBeat = StringId.StringToHash("NetEventId.HeartBeat"); + public static int ConnectTcp = StringId.StringToHash("NetEventId.ConnectTcp"); + public static int ConnectUdp = StringId.StringToHash("NetEventId.ConnectUdp"); + } +} diff --git a/TEngineHotUpdate/src/TEngineCore/Net/ProtoUtils.cs b/TEngineHotUpdate/src/TEngineCore/Net/ProtoUtils.cs new file mode 100644 index 00000000..a5d91b09 --- /dev/null +++ b/TEngineHotUpdate/src/TEngineCore/Net/ProtoUtils.cs @@ -0,0 +1,52 @@ +using System.IO; +using JetBrains.Annotations; + +namespace TEngineCore.Net +{ + public class ProtoUtils + { + /// + /// 序列化 MainPack -> byte[] + /// + /// + /// + /// + [CanBeNull] + public static byte[] Serialize(T mainPack) where T : class + { + try + { + using (var stream = new System.IO.MemoryStream()) + { + ProtoBuf.Serializer.Serialize(stream, mainPack); + return stream.ToArray(); + } + } + catch (IOException ex) + { + TLogger.LogError($"[Serialize] Error:{ex.Message}, {ex.Data["StackTrace"]}"); + return null; + } + } + + /// + /// 反序列化 + /// + /// + /// + /// + [CanBeNull] + public static T DeSerialize(byte[] buffer) where T : class + { + try + { + return ProtoBuf.Serializer.Deserialize(typeof(T), new System.IO.MemoryStream(buffer)) as T; + } + catch (IOException ex) + { + TLogger.LogError(($"[DeSerialize] 错误:{ex.Message}, {ex.Data["StackTrace"]}")); + return null; + } + } + } +}