From 4632a0c09958ffdaaa30bf973efa304d8308b783 Mon Sep 17 00:00:00 2001
From: ALEXTANG <574809918@qq.com>
Date: Fri, 19 May 2023 00:31:15 +0800
Subject: [PATCH] [+] UpdateNetwork Module
[+] UpdateNetwork Module
---
.../GameLogic/Network/ClientConnectWatcher.cs | 166 ++++++++
.../Network/ClientConnectWatcher.cs.meta | 3 +
.../HotFix/GameLogic/Network/GameClient.cs | 374 ++++++++++++++++++
.../GameLogic/Network/GameClient.cs.meta | 3 +
.../HotFix/GameLogic/Network/HeartBeat.cs | 19 -
.../GameLogic/Network/HeartBeat.cs.meta | 3 -
.../HotFix/GameLogic/Network/MsgDispatcher.cs | 264 +++++++++++++
.../GameLogic/Network/MsgDispatcher.cs.meta | 3 +
.../GameLogic/Network/NetworkChannelHelper.cs | 58 +--
.../GameLogic/Network/NetworkCore.meta} | 0
.../Network/NetworkCore}/AddressFamily.cs | 0
.../NetworkCore}/AddressFamily.cs.meta | 0
.../Network/NetworkCore}/Interface.meta | 0
.../NetworkCore}/Interface/INetworkChannel.cs | 6 +-
.../Interface/INetworkChannel.cs.meta | 0
.../Interface/INetworkChannelHelper.cs | 5 +-
.../Interface/INetworkChannelHelper.cs.meta | 0
.../NetworkCore}/Interface/INetworkManager.cs | 0
.../Interface/INetworkManager.cs.meta | 0
.../NetworkCore}/Interface/IPacketHeader.cs | 0
.../Interface/IPacketHeader.cs.meta | 0
.../GameLogic/Network/NetworkCore}/Kcp.meta | 0
.../Network/NetworkCore}/Kcp/Core.meta | 0
.../NetworkCore}/Kcp/Core/FakeKcpIO.cs | 0
.../NetworkCore}/Kcp/Core/FakeKcpIO.cs.meta | 0
.../NetworkCore}/Kcp/Core/IKcpInterface.cs | 0
.../Kcp/Core/IKcpInterface.cs.meta | 0
.../NetworkCore}/Kcp/Core/IKcpSegment.cs | 0
.../NetworkCore}/Kcp/Core/IKcpSegment.cs.meta | 0
.../Network/NetworkCore}/Kcp/Core/Kcp.cs | 0
.../Network/NetworkCore}/Kcp/Core/Kcp.cs.meta | 0
.../Network/NetworkCore}/Kcp/Core/KcpCore.cs | 0
.../NetworkCore}/Kcp/Core/KcpCore.cs.meta | 0
.../Network/NetworkCore}/Kcp/Core/KcpIO.cs | 0
.../NetworkCore}/Kcp/Core/KcpIO.cs.meta | 0
.../NetworkCore}/Kcp/Core/KcpOutputWriter.cs | 0
.../Kcp/Core/KcpOutputWriter.cs.meta | 0
.../NetworkCore}/Kcp/Core/KcpSegment.cs | 0
.../NetworkCore}/Kcp/Core/KcpSegment.cs.meta | 0
.../Network/NetworkCore}/Kcp/Core/KcpTrace.cs | 0
.../NetworkCore}/Kcp/Core/KcpTrace.cs.meta | 0
.../NetworkCore}/Kcp/Core/SegManager.cs | 0
.../NetworkCore}/Kcp/Core/SegManager.cs.meta | 0
.../NetworkCore}/Kcp/Core/SimpleKcpClient.cs | 0
.../Kcp/Core/SimpleKcpClient.cs.meta | 0
.../NetworkCore}/Kcp/Core/SimpleKcpServer.cs | 0
.../Kcp/Core/SimpleKcpServer.cs.meta | 0
.../Network/NetworkCore}/Kcp/Core/Utility.cs | 0
.../NetworkCore}/Kcp/Core/Utility.cs.meta | 0
.../Kcp/NetworkManager.KcpNetworkChannel.cs | 0
.../NetworkManager.KcpNetworkChannel.cs.meta | 0
.../GameLogic/Network/NetworkCore}/NetUtil.cs | 0
.../Network/NetworkCore}/NetUtil.cs.meta | 0
.../GameLogic/Network/NetworkCore}/Network.cs | 0
.../Network/NetworkCore}/Network.cs.meta | 0
.../Network/NetworkCore}/NetworkErrorCode.cs | 0
.../NetworkCore}/NetworkErrorCode.cs.meta | 0
.../Network/NetworkCore}/NetworkEvent.cs | 0
.../Network/NetworkCore}/NetworkEvent.cs.meta | 0
.../NetworkManager.ConnectState.cs | 0
.../NetworkManager.ConnectState.cs.meta | 0
.../NetworkManager.HeartBeatState.cs | 0
.../NetworkManager.HeartBeatState.cs.meta | 0
.../NetworkManager.NetworkChannelBase.cs | 29 +-
.../NetworkManager.NetworkChannelBase.cs.meta | 0
.../NetworkManager.ReceiveState.cs | 0
.../NetworkManager.ReceiveState.cs.meta | 0
.../NetworkCore}/NetworkManager.SendState.cs | 0
.../NetworkManager.SendState.cs.meta | 0
.../NetworkManager.TcpNetworkChannel.cs | 0
.../NetworkManager.TcpNetworkChannel.cs.meta | 0
...anager.TcpWithSyncReceiveNetworkChannel.cs | 0
...r.TcpWithSyncReceiveNetworkChannel.cs.meta | 0
.../NetworkManager.UdpNetworkChannel.cs | 0
.../NetworkManager.UdpNetworkChannel.cs.meta | 0
.../Network/NetworkCore}/NetworkManager.cs | 33 +-
.../NetworkCore}/NetworkManager.cs.meta | 0
.../Network/NetworkCore}/ServiceType.cs | 0
.../Network/NetworkCore}/ServiceType.cs.meta | 0
.../HotFix/GameLogic/Network/PacketBase.cs | 24 --
.../GameLogic/Network/PacketBase.cs.meta | 3 -
.../HotFix/GameLogic/Network/ProtoPacket.cs | 15 -
.../GameLogic/Network/ProtoPacket.cs.meta | 3 -
.../GameLogic/Network/ProtobufUtility.cs | 10 +
.../GameLogic/Network/ProtobufUtils.cs.meta | 2 +-
.../Runtime/GameFramework/Network/Packet.cs | 18 -
.../GameFramework/Network/Packet.cs.meta | 3 -
87 files changed, 881 insertions(+), 163 deletions(-)
create mode 100644 Assets/GameScripts/HotFix/GameLogic/Network/ClientConnectWatcher.cs
create mode 100644 Assets/GameScripts/HotFix/GameLogic/Network/ClientConnectWatcher.cs.meta
create mode 100644 Assets/GameScripts/HotFix/GameLogic/Network/GameClient.cs
create mode 100644 Assets/GameScripts/HotFix/GameLogic/Network/GameClient.cs.meta
delete mode 100644 Assets/GameScripts/HotFix/GameLogic/Network/HeartBeat.cs
delete mode 100644 Assets/GameScripts/HotFix/GameLogic/Network/HeartBeat.cs.meta
create mode 100644 Assets/GameScripts/HotFix/GameLogic/Network/MsgDispatcher.cs
create mode 100644 Assets/GameScripts/HotFix/GameLogic/Network/MsgDispatcher.cs.meta
rename Assets/{TEngine/Runtime/GameFramework/Network.meta => GameScripts/HotFix/GameLogic/Network/NetworkCore.meta} (100%)
rename Assets/{TEngine/Runtime/GameFramework/Network => GameScripts/HotFix/GameLogic/Network/NetworkCore}/AddressFamily.cs (100%)
rename Assets/{TEngine/Runtime/GameFramework/Network => GameScripts/HotFix/GameLogic/Network/NetworkCore}/AddressFamily.cs.meta (100%)
rename Assets/{TEngine/Runtime/GameFramework/Network => GameScripts/HotFix/GameLogic/Network/NetworkCore}/Interface.meta (100%)
rename Assets/{TEngine/Runtime/GameFramework/Network => GameScripts/HotFix/GameLogic/Network/NetworkCore}/Interface/INetworkChannel.cs (96%)
rename Assets/{TEngine/Runtime/GameFramework/Network => GameScripts/HotFix/GameLogic/Network/NetworkCore}/Interface/INetworkChannel.cs.meta (100%)
rename Assets/{TEngine/Runtime/GameFramework/Network => GameScripts/HotFix/GameLogic/Network/NetworkCore}/Interface/INetworkChannelHelper.cs (92%)
rename Assets/{TEngine/Runtime/GameFramework/Network => GameScripts/HotFix/GameLogic/Network/NetworkCore}/Interface/INetworkChannelHelper.cs.meta (100%)
rename Assets/{TEngine/Runtime/GameFramework/Network => GameScripts/HotFix/GameLogic/Network/NetworkCore}/Interface/INetworkManager.cs (100%)
rename Assets/{TEngine/Runtime/GameFramework/Network => GameScripts/HotFix/GameLogic/Network/NetworkCore}/Interface/INetworkManager.cs.meta (100%)
rename Assets/{TEngine/Runtime/GameFramework/Network => GameScripts/HotFix/GameLogic/Network/NetworkCore}/Interface/IPacketHeader.cs (100%)
rename Assets/{TEngine/Runtime/GameFramework/Network => GameScripts/HotFix/GameLogic/Network/NetworkCore}/Interface/IPacketHeader.cs.meta (100%)
rename Assets/{TEngine/Runtime/GameFramework/Network => GameScripts/HotFix/GameLogic/Network/NetworkCore}/Kcp.meta (100%)
rename Assets/{TEngine/Runtime/GameFramework/Network => GameScripts/HotFix/GameLogic/Network/NetworkCore}/Kcp/Core.meta (100%)
rename Assets/{TEngine/Runtime/GameFramework/Network => GameScripts/HotFix/GameLogic/Network/NetworkCore}/Kcp/Core/FakeKcpIO.cs (100%)
rename Assets/{TEngine/Runtime/GameFramework/Network => GameScripts/HotFix/GameLogic/Network/NetworkCore}/Kcp/Core/FakeKcpIO.cs.meta (100%)
rename Assets/{TEngine/Runtime/GameFramework/Network => GameScripts/HotFix/GameLogic/Network/NetworkCore}/Kcp/Core/IKcpInterface.cs (100%)
rename Assets/{TEngine/Runtime/GameFramework/Network => GameScripts/HotFix/GameLogic/Network/NetworkCore}/Kcp/Core/IKcpInterface.cs.meta (100%)
rename Assets/{TEngine/Runtime/GameFramework/Network => GameScripts/HotFix/GameLogic/Network/NetworkCore}/Kcp/Core/IKcpSegment.cs (100%)
rename Assets/{TEngine/Runtime/GameFramework/Network => GameScripts/HotFix/GameLogic/Network/NetworkCore}/Kcp/Core/IKcpSegment.cs.meta (100%)
rename Assets/{TEngine/Runtime/GameFramework/Network => GameScripts/HotFix/GameLogic/Network/NetworkCore}/Kcp/Core/Kcp.cs (100%)
rename Assets/{TEngine/Runtime/GameFramework/Network => GameScripts/HotFix/GameLogic/Network/NetworkCore}/Kcp/Core/Kcp.cs.meta (100%)
rename Assets/{TEngine/Runtime/GameFramework/Network => GameScripts/HotFix/GameLogic/Network/NetworkCore}/Kcp/Core/KcpCore.cs (100%)
rename Assets/{TEngine/Runtime/GameFramework/Network => GameScripts/HotFix/GameLogic/Network/NetworkCore}/Kcp/Core/KcpCore.cs.meta (100%)
rename Assets/{TEngine/Runtime/GameFramework/Network => GameScripts/HotFix/GameLogic/Network/NetworkCore}/Kcp/Core/KcpIO.cs (100%)
rename Assets/{TEngine/Runtime/GameFramework/Network => GameScripts/HotFix/GameLogic/Network/NetworkCore}/Kcp/Core/KcpIO.cs.meta (100%)
rename Assets/{TEngine/Runtime/GameFramework/Network => GameScripts/HotFix/GameLogic/Network/NetworkCore}/Kcp/Core/KcpOutputWriter.cs (100%)
rename Assets/{TEngine/Runtime/GameFramework/Network => GameScripts/HotFix/GameLogic/Network/NetworkCore}/Kcp/Core/KcpOutputWriter.cs.meta (100%)
rename Assets/{TEngine/Runtime/GameFramework/Network => GameScripts/HotFix/GameLogic/Network/NetworkCore}/Kcp/Core/KcpSegment.cs (100%)
rename Assets/{TEngine/Runtime/GameFramework/Network => GameScripts/HotFix/GameLogic/Network/NetworkCore}/Kcp/Core/KcpSegment.cs.meta (100%)
rename Assets/{TEngine/Runtime/GameFramework/Network => GameScripts/HotFix/GameLogic/Network/NetworkCore}/Kcp/Core/KcpTrace.cs (100%)
rename Assets/{TEngine/Runtime/GameFramework/Network => GameScripts/HotFix/GameLogic/Network/NetworkCore}/Kcp/Core/KcpTrace.cs.meta (100%)
rename Assets/{TEngine/Runtime/GameFramework/Network => GameScripts/HotFix/GameLogic/Network/NetworkCore}/Kcp/Core/SegManager.cs (100%)
rename Assets/{TEngine/Runtime/GameFramework/Network => GameScripts/HotFix/GameLogic/Network/NetworkCore}/Kcp/Core/SegManager.cs.meta (100%)
rename Assets/{TEngine/Runtime/GameFramework/Network => GameScripts/HotFix/GameLogic/Network/NetworkCore}/Kcp/Core/SimpleKcpClient.cs (100%)
rename Assets/{TEngine/Runtime/GameFramework/Network => GameScripts/HotFix/GameLogic/Network/NetworkCore}/Kcp/Core/SimpleKcpClient.cs.meta (100%)
rename Assets/{TEngine/Runtime/GameFramework/Network => GameScripts/HotFix/GameLogic/Network/NetworkCore}/Kcp/Core/SimpleKcpServer.cs (100%)
rename Assets/{TEngine/Runtime/GameFramework/Network => GameScripts/HotFix/GameLogic/Network/NetworkCore}/Kcp/Core/SimpleKcpServer.cs.meta (100%)
rename Assets/{TEngine/Runtime/GameFramework/Network => GameScripts/HotFix/GameLogic/Network/NetworkCore}/Kcp/Core/Utility.cs (100%)
rename Assets/{TEngine/Runtime/GameFramework/Network => GameScripts/HotFix/GameLogic/Network/NetworkCore}/Kcp/Core/Utility.cs.meta (100%)
rename Assets/{TEngine/Runtime/GameFramework/Network => GameScripts/HotFix/GameLogic/Network/NetworkCore}/Kcp/NetworkManager.KcpNetworkChannel.cs (100%)
rename Assets/{TEngine/Runtime/GameFramework/Network => GameScripts/HotFix/GameLogic/Network/NetworkCore}/Kcp/NetworkManager.KcpNetworkChannel.cs.meta (100%)
rename Assets/{TEngine/Runtime/GameFramework/Network => GameScripts/HotFix/GameLogic/Network/NetworkCore}/NetUtil.cs (100%)
rename Assets/{TEngine/Runtime/GameFramework/Network => GameScripts/HotFix/GameLogic/Network/NetworkCore}/NetUtil.cs.meta (100%)
rename Assets/{TEngine/Runtime/GameFramework/Network => GameScripts/HotFix/GameLogic/Network/NetworkCore}/Network.cs (100%)
rename Assets/{TEngine/Runtime/GameFramework/Network => GameScripts/HotFix/GameLogic/Network/NetworkCore}/Network.cs.meta (100%)
rename Assets/{TEngine/Runtime/GameFramework/Network => GameScripts/HotFix/GameLogic/Network/NetworkCore}/NetworkErrorCode.cs (100%)
rename Assets/{TEngine/Runtime/GameFramework/Network => GameScripts/HotFix/GameLogic/Network/NetworkCore}/NetworkErrorCode.cs.meta (100%)
rename Assets/{TEngine/Runtime/GameFramework/Network => GameScripts/HotFix/GameLogic/Network/NetworkCore}/NetworkEvent.cs (100%)
rename Assets/{TEngine/Runtime/GameFramework/Network => GameScripts/HotFix/GameLogic/Network/NetworkCore}/NetworkEvent.cs.meta (100%)
rename Assets/{TEngine/Runtime/GameFramework/Network => GameScripts/HotFix/GameLogic/Network/NetworkCore}/NetworkManager.ConnectState.cs (100%)
rename Assets/{TEngine/Runtime/GameFramework/Network => GameScripts/HotFix/GameLogic/Network/NetworkCore}/NetworkManager.ConnectState.cs.meta (100%)
rename Assets/{TEngine/Runtime/GameFramework/Network => GameScripts/HotFix/GameLogic/Network/NetworkCore}/NetworkManager.HeartBeatState.cs (100%)
rename Assets/{TEngine/Runtime/GameFramework/Network => GameScripts/HotFix/GameLogic/Network/NetworkCore}/NetworkManager.HeartBeatState.cs.meta (100%)
rename Assets/{TEngine/Runtime/GameFramework/Network => GameScripts/HotFix/GameLogic/Network/NetworkCore}/NetworkManager.NetworkChannelBase.cs (96%)
rename Assets/{TEngine/Runtime/GameFramework/Network => GameScripts/HotFix/GameLogic/Network/NetworkCore}/NetworkManager.NetworkChannelBase.cs.meta (100%)
rename Assets/{TEngine/Runtime/GameFramework/Network => GameScripts/HotFix/GameLogic/Network/NetworkCore}/NetworkManager.ReceiveState.cs (100%)
rename Assets/{TEngine/Runtime/GameFramework/Network => GameScripts/HotFix/GameLogic/Network/NetworkCore}/NetworkManager.ReceiveState.cs.meta (100%)
rename Assets/{TEngine/Runtime/GameFramework/Network => GameScripts/HotFix/GameLogic/Network/NetworkCore}/NetworkManager.SendState.cs (100%)
rename Assets/{TEngine/Runtime/GameFramework/Network => GameScripts/HotFix/GameLogic/Network/NetworkCore}/NetworkManager.SendState.cs.meta (100%)
rename Assets/{TEngine/Runtime/GameFramework/Network => GameScripts/HotFix/GameLogic/Network/NetworkCore}/NetworkManager.TcpNetworkChannel.cs (100%)
rename Assets/{TEngine/Runtime/GameFramework/Network => GameScripts/HotFix/GameLogic/Network/NetworkCore}/NetworkManager.TcpNetworkChannel.cs.meta (100%)
rename Assets/{TEngine/Runtime/GameFramework/Network => GameScripts/HotFix/GameLogic/Network/NetworkCore}/NetworkManager.TcpWithSyncReceiveNetworkChannel.cs (100%)
rename Assets/{TEngine/Runtime/GameFramework/Network => GameScripts/HotFix/GameLogic/Network/NetworkCore}/NetworkManager.TcpWithSyncReceiveNetworkChannel.cs.meta (100%)
rename Assets/{TEngine/Runtime/GameFramework/Network => GameScripts/HotFix/GameLogic/Network/NetworkCore}/NetworkManager.UdpNetworkChannel.cs (100%)
rename Assets/{TEngine/Runtime/GameFramework/Network => GameScripts/HotFix/GameLogic/Network/NetworkCore}/NetworkManager.UdpNetworkChannel.cs.meta (100%)
rename Assets/{TEngine/Runtime/GameFramework/Network => GameScripts/HotFix/GameLogic/Network/NetworkCore}/NetworkManager.cs (94%)
rename Assets/{TEngine/Runtime/GameFramework/Network => GameScripts/HotFix/GameLogic/Network/NetworkCore}/NetworkManager.cs.meta (100%)
rename Assets/{TEngine/Runtime/GameFramework/Network => GameScripts/HotFix/GameLogic/Network/NetworkCore}/ServiceType.cs (100%)
rename Assets/{TEngine/Runtime/GameFramework/Network => GameScripts/HotFix/GameLogic/Network/NetworkCore}/ServiceType.cs.meta (100%)
delete mode 100644 Assets/GameScripts/HotFix/GameLogic/Network/PacketBase.cs
delete mode 100644 Assets/GameScripts/HotFix/GameLogic/Network/PacketBase.cs.meta
delete mode 100644 Assets/GameScripts/HotFix/GameLogic/Network/ProtoPacket.cs
delete mode 100644 Assets/GameScripts/HotFix/GameLogic/Network/ProtoPacket.cs.meta
delete mode 100644 Assets/TEngine/Runtime/GameFramework/Network/Packet.cs
delete mode 100644 Assets/TEngine/Runtime/GameFramework/Network/Packet.cs.meta
diff --git a/Assets/GameScripts/HotFix/GameLogic/Network/ClientConnectWatcher.cs b/Assets/GameScripts/HotFix/GameLogic/Network/ClientConnectWatcher.cs
new file mode 100644
index 00000000..e62f0ede
--- /dev/null
+++ b/Assets/GameScripts/HotFix/GameLogic/Network/ClientConnectWatcher.cs
@@ -0,0 +1,166 @@
+using TEngine;
+
+namespace GameLogic
+{
+ public enum ClientConnectWatcherStatus
+ {
+ StatusInit,
+ StatusReconnectAuto,
+ StatusReconnectConfirm,
+ StatusWaitExit
+ }
+
+ public class ClientConnectWatcher
+ {
+ private readonly GameClient _client;
+ private ClientConnectWatcherStatus _status;
+ private float _statusTime;
+ private int _reconnectCnt = 0;
+ private int _disconnectReason = 0;
+
+ private bool _enable = false;
+
+ public bool Enable
+ {
+ get => _enable;
+ set
+ {
+ if (_enable != value)
+ {
+ _enable = value;
+ if (_enable)
+ {
+ OnEnable();
+ }
+ else
+ {
+ OnDisable();
+ }
+ }
+ }
+ }
+
+ private ClientConnectWatcherStatus Status
+ {
+ get => _status;
+ set
+ {
+ if (_status == value) return;
+ _status = value;
+ _statusTime = NowTime;
+ }
+ }
+
+ private float NowTime => GameTime.unscaledTime;
+
+ public ClientConnectWatcher(GameClient client)
+ {
+ _client = client;
+ _statusTime = NowTime;
+ _status = ClientConnectWatcherStatus.StatusInit;
+ }
+
+ public void Update()
+ {
+ if (!_enable)
+ {
+ return;
+ }
+
+ if (_client.IsEntered)
+ {
+ return;
+ }
+
+ switch (_status)
+ {
+ case ClientConnectWatcherStatus.StatusInit:
+ UpdateOnInitStatus();
+ break;
+ case ClientConnectWatcherStatus.StatusReconnectAuto:
+ UpdateOnReconnectAuto();
+ break;
+ case ClientConnectWatcherStatus.StatusReconnectConfirm:
+ UpdateOnReconnectConfirm();
+ break;
+ case ClientConnectWatcherStatus.StatusWaitExit:
+ UpdateOnWaitExit();
+ break;
+ }
+ }
+
+ public void OnReConnect()
+ {
+ if (_status == ClientConnectWatcherStatus.StatusReconnectConfirm)
+ {
+ Status = ClientConnectWatcherStatus.StatusReconnectAuto;
+ }
+ }
+
+ void UpdateOnInitStatus()
+ {
+ int autoReconnectMaxCount = 4;
+ if (_reconnectCnt <= autoReconnectMaxCount)
+ {
+ if (_reconnectCnt == 0)
+ {
+ _disconnectReason = _client.LastNetErrCode;
+ }
+
+ Status = ClientConnectWatcherStatus.StatusReconnectAuto;
+ _reconnectCnt++;
+
+ //重连
+ _client.Reconnect();
+ }
+ else
+ {
+ Status = ClientConnectWatcherStatus.StatusReconnectConfirm;
+ _reconnectCnt++;
+ // UISys.Mgr.ShowUI(GAME_UI_TYPE.Tip_NetDisconn, UISys.Mgr.GetUIWindowParam().SetParam("errCode", m_disconnectReason));
+ }
+ }
+
+ void UpdateOnReconnectAuto()
+ {
+ if (_client.IsEntered)
+ {
+ Status = ClientConnectWatcherStatus.StatusInit;
+ _reconnectCnt = 0;
+ return;
+ }
+
+ float nowTime = NowTime;
+ var timeoutTime = 10f;
+
+ if (_statusTime + timeoutTime < nowTime)
+ {
+ Log.Error("UpdateOnReconnectAuto timeout: {0}", timeoutTime);
+
+ //切换到默认的,下一帧继续判断是否需要自动还是手动
+ Status = ClientConnectWatcherStatus.StatusInit;
+ }
+ }
+
+ void UpdateOnReconnectConfirm()
+ {
+
+ }
+
+ void UpdateOnWaitExit()
+ {
+ }
+
+ private void OnDisable()
+ {
+ Status = ClientConnectWatcherStatus.StatusInit;
+ _reconnectCnt = 0;
+ }
+
+ private void OnEnable()
+ {
+ Status = ClientConnectWatcherStatus.StatusInit;
+ _reconnectCnt = 0;
+ }
+ }
+}
\ No newline at end of file
diff --git a/Assets/GameScripts/HotFix/GameLogic/Network/ClientConnectWatcher.cs.meta b/Assets/GameScripts/HotFix/GameLogic/Network/ClientConnectWatcher.cs.meta
new file mode 100644
index 00000000..ce6c15a3
--- /dev/null
+++ b/Assets/GameScripts/HotFix/GameLogic/Network/ClientConnectWatcher.cs.meta
@@ -0,0 +1,3 @@
+fileFormatVersion: 2
+guid: 3e4e637f3da340dd9512150c3e2ff087
+timeCreated: 1684334948
\ No newline at end of file
diff --git a/Assets/GameScripts/HotFix/GameLogic/Network/GameClient.cs b/Assets/GameScripts/HotFix/GameLogic/Network/GameClient.cs
new file mode 100644
index 00000000..372e1117
--- /dev/null
+++ b/Assets/GameScripts/HotFix/GameLogic/Network/GameClient.cs
@@ -0,0 +1,374 @@
+using GameBase;
+using GameProto;
+using TEngine;
+using CSPkg = GameProto.CSPkg;
+
+namespace GameLogic
+{
+ public enum GameClientStatus
+ {
+ StatusInit, //初始化
+ StatusReconnect, //重新连接
+ StatusClose, //断开连接
+ StatusLogin, //登录中
+ StatusEnter, //AccountLogin成功,进入服务器了
+ }
+
+ public enum CsMsgResult
+ {
+ NoError = 0,
+ NetworkError = 1,
+ InternalError = 2,
+ MsgTimeOut = 3,
+ PingTimeOut = 4,
+ }
+
+ //定义消息回报的回调接口
+ public delegate void CsMsgDelegate(CsMsgResult result, CSPkg msg);
+
+ ///
+ /// 统计网络协议的接口
+ ///
+ public delegate void CsMsgStatDelegate(int cmdID, int pkgSize);
+
+ public class GameClient : Singleton
+ {
+ public INetworkChannel Channel;
+
+ private GameClientStatus m_status = GameClientStatus.StatusInit;
+
+ private MsgDispatcher m_dispatcher;
+
+ private ClientConnectWatcher m_connectWatcher;
+
+ private float m_lastLogDisconnectErrTime = 0f;
+
+ private int m_lastNetErrCode = 0;
+
+ public int LastNetErrCode => m_lastNetErrCode;
+
+ public GameClientStatus Status
+ {
+ get => m_status;
+ set => m_status = value;
+ }
+
+ public bool IsEntered => m_status == GameClientStatus.StatusEnter;
+
+ ///
+ /// 连续心跳超时
+ ///
+ private int m_heatBeatTimeoutNum = 0;
+
+ private int m_ping = -1;
+
+ private float NowTime => GameTime.unscaledTime;
+
+ private string _lastHost = null;
+ private int _lastPort = 0;
+
+ public GameClient()
+ {
+ m_connectWatcher = new ClientConnectWatcher(this);
+ m_dispatcher = new MsgDispatcher();
+ m_dispatcher.SetTimeout(5f);
+ }
+
+ public void Connect(string host, int port, bool reconnect = false)
+ {
+ ResetParam();
+ if (!reconnect)
+ {
+ SetWatchReconnect(false);
+ }
+
+ if (reconnect)
+ {
+ // GameEvent.Get().ShowWaitUITip(WaitUISeq.LOGINWORLD_SEQID, G.R(TextDefine.ID_TIPS_RECONNECTING));
+ }
+ else
+ {
+ // GameEvent.Get().ShowWaitUI(WaitUISeq.LOGINWORLD_SEQID);
+ }
+
+ _lastHost = host;
+ _lastPort = port;
+
+ Channel = TEngine.Network.CreateNetworkChannel("GameClient", ServiceType.Tcp, new NetworkChannelHelper());
+ Channel.Connect(host, port);
+ }
+
+ public void Reconnect()
+ {
+ if (string.IsNullOrEmpty(_lastHost) || _lastPort <= 0)
+ {
+ // GameModule.UI.ShowTipMsg("Invalid reconnect param");
+ return;
+ }
+
+ m_connectWatcher.OnReConnect();
+ Connect(_lastHost, _lastPort, true);
+ }
+
+
+ public void Shutdown()
+ {
+ Channel.Close();
+ m_status = GameClientStatus.StatusInit;
+ }
+
+ public bool SendCsMsg(CSPkg reqPkg)
+ {
+ if (!IsStatusCanSendMsg(reqPkg.Head.MsgId))
+ {
+ return false;
+ }
+
+ return DoSendData(reqPkg);
+ }
+
+ public bool IsStatusCanSendMsg(uint msgId)
+ {
+ bool canSend = false;
+ if (m_status == GameClientStatus.StatusLogin)
+ {
+ canSend = (msgId == (uint)CSMsgID.CsCmdActLoginReq);
+ }
+
+ if (m_status == GameClientStatus.StatusEnter)
+ {
+ canSend = true;
+ }
+
+ if (!canSend)
+ {
+ float nowTime = NowTime;
+ if (m_lastLogDisconnectErrTime + 5 < nowTime)
+ {
+ Log.Error("GameClient not connected, send msg failed, msgId[{0}]", msgId);
+ m_lastLogDisconnectErrTime = nowTime;
+ }
+
+ //UISys.Mgr.ShowTipMsg(TextDefine.ID_ERR_NETWORKD_DISCONNECT);
+ }
+
+ return canSend;
+ }
+
+ public bool SendCsMsg(CSPkg reqPkg, uint resCmd, CsMsgDelegate resHandler = null, bool needShowWaitUI = true)
+ {
+ if (!IsStatusCanSendMsg(reqPkg.Head.MsgId))
+ {
+ return false;
+ }
+
+ var ret = DoSendData(reqPkg);
+ if (!ret)
+ {
+ if (resHandler != null)
+ {
+ resHandler(CsMsgResult.InternalError, null);
+ }
+
+ m_dispatcher.NotifyCmdError(resCmd, CsMsgResult.InternalError);
+ }
+ else
+ {
+ //注册消息
+ if (resHandler != null)
+ {
+ m_dispatcher.RegSeqHandle(reqPkg.Head.Echo, resCmd, resHandler);
+ if (reqPkg.Head.Echo > 0 && IsWaitingCmd(resCmd) && needShowWaitUI)
+ {
+ // TODO
+ // GameEvent.Get().ShowWaitUI(reqPkg.Head.Echo);
+ }
+ }
+ }
+
+ return ret;
+ }
+
+ private bool DoSendData(CSPkg reqPkg)
+ {
+ if (!IsIgnoreLog(reqPkg.Head.MsgId))
+ {
+ Log.Debug("[c-s] CmdId[{0}]\n{1}", reqPkg.Head.MsgId, reqPkg.Body.ToString());
+ }
+ var sendRet = Channel.Send(reqPkg);
+ return sendRet;
+ return true;
+ }
+
+ private bool IsIgnoreLog(uint msgId)
+ {
+ bool ignoreLog = false;
+ switch (msgId)
+ {
+ case (uint)CSMsgID.CsCmdHeatbeatReq:
+ case (uint)CSMsgID.CsCmdHeatbeatRes:
+ ignoreLog = true;
+ break;
+ }
+
+ return ignoreLog;
+ }
+
+ public static bool IsWaitingCmd(uint msgId)
+ {
+ //心跳包不需要读条等待
+ if (msgId == (uint)CSMsgID.CsCmdHeatbeatRes)
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ private void ResetParam()
+ {
+ m_lastLogDisconnectErrTime = 0f;
+ m_heatBeatTimeoutNum = 0;
+ _lastHbTime = 0f;
+ m_ping = -1;
+ m_lastNetErrCode = 0;
+ }
+
+ public void OnUpdate()
+ {
+ m_dispatcher.Update();
+ TickHeartBeat();
+ CheckHeatBeatTimeout();
+ m_connectWatcher.Update();
+ }
+
+ ///
+ /// 设置加密密钥
+ ///
+ ///
+ public void SetEncryptKey(string key)
+ {
+ }
+
+ ///
+ /// 设置是否需要监控网络重连。
+ /// 登录成功后,开启监控,可以自动重连或者提示玩家重连。
+ ///
+ ///
+ public void SetWatchReconnect(bool needWatch)
+ {
+ m_connectWatcher.Enable = needWatch;
+ }
+
+ public bool IsNetworkOkAndLogin()
+ {
+ return m_status == GameClientStatus.StatusEnter;
+ }
+
+ #region 心跳处理
+
+ ///
+ /// 最近一次心跳的时间
+ ///
+ private float _lastHbTime = 0f;
+
+ ///
+ /// 心跳间隔
+ ///
+ private readonly float _heartBeatDurTime = 5;
+
+ ///
+ /// 心跳超时的最大次数
+ ///
+ private const int HeatBeatTimeoutMaxCount = 2;
+
+ private bool CheckHeatBeatTimeout()
+ {
+ if (m_heatBeatTimeoutNum >= HeatBeatTimeoutMaxCount)
+ {
+ //断开连接
+ Shutdown();
+
+ //准备重连
+ m_heatBeatTimeoutNum = 0;
+ Status = GameClientStatus.StatusClose;
+ Log.Error("heat beat detect timeout");
+ return false;
+ }
+
+ return true;
+ }
+
+ void TickHeartBeat()
+ {
+ if (Status != GameClientStatus.StatusEnter)
+ {
+ return;
+ }
+
+ var nowTime = NowTime;
+ if (_lastHbTime + _heartBeatDurTime < nowTime)
+ {
+ _lastHbTime = nowTime;
+
+ CSPkg heatPkg = ProtobufUtility.BuildCsMsg((int)CSMsgID.CsCmdHeatbeatReq);
+ heatPkg.Body.HeatBeatReq = new CSHeatBeatReq { HeatEchoTime = _lastHbTime };
+ SendCsMsg(heatPkg, (int)CSMsgID.CsCmdHeatbeatRes, HandleHeatBeatRes);
+ }
+ }
+
+ void HandleHeatBeatRes(CsMsgResult result, CSPkg msg)
+ {
+ if (result != CsMsgResult.NoError)
+ {
+ //如果是超时了,则标记最近收到包的次数
+ if (result == CsMsgResult.MsgTimeOut)
+ {
+ m_heatBeatTimeoutNum++;
+ Log.Warning("heat beat timeout: {0}", m_heatBeatTimeoutNum);
+ }
+ }
+ else
+ {
+ var resBody = msg.Body.HeatBeatRes;
+ float diffTime = NowTime - resBody.HeatEchoTime;
+ m_ping = (int)(diffTime * 1000);
+ m_heatBeatTimeoutNum = 0;
+ }
+ }
+
+ #endregion
+
+ #region Ping值
+
+ ///
+ /// ping值
+ ///
+ public int Ping
+ {
+ get
+ {
+ if (IsPingValid())
+ {
+ return m_ping / 4;
+ }
+ else
+ {
+ return 0;
+ }
+ }
+ }
+
+ public bool IsPingValid()
+ {
+ if (IsNetworkOkAndLogin())
+ {
+ return m_ping >= 0;
+ }
+
+ return false;
+ }
+
+ #endregion
+ }
+}
\ No newline at end of file
diff --git a/Assets/GameScripts/HotFix/GameLogic/Network/GameClient.cs.meta b/Assets/GameScripts/HotFix/GameLogic/Network/GameClient.cs.meta
new file mode 100644
index 00000000..b77d9457
--- /dev/null
+++ b/Assets/GameScripts/HotFix/GameLogic/Network/GameClient.cs.meta
@@ -0,0 +1,3 @@
+fileFormatVersion: 2
+guid: 8c5441725c9f4d98a7790dc76a6a0c48
+timeCreated: 1684331687
\ No newline at end of file
diff --git a/Assets/GameScripts/HotFix/GameLogic/Network/HeartBeat.cs b/Assets/GameScripts/HotFix/GameLogic/Network/HeartBeat.cs
deleted file mode 100644
index 13288a2c..00000000
--- a/Assets/GameScripts/HotFix/GameLogic/Network/HeartBeat.cs
+++ /dev/null
@@ -1,19 +0,0 @@
-using System;
-using ProtoBuf;
-
-namespace GameLogic
-{
- [Serializable, ProtoContract(Name = @"HeartBeat")]
- public class HeartBeat : PacketBase
- {
- public HeartBeat()
- {
- }
-
- public override int Id => 1;
-
- public override void Clear()
- {
- }
- }
-}
\ No newline at end of file
diff --git a/Assets/GameScripts/HotFix/GameLogic/Network/HeartBeat.cs.meta b/Assets/GameScripts/HotFix/GameLogic/Network/HeartBeat.cs.meta
deleted file mode 100644
index 56003068..00000000
--- a/Assets/GameScripts/HotFix/GameLogic/Network/HeartBeat.cs.meta
+++ /dev/null
@@ -1,3 +0,0 @@
-fileFormatVersion: 2
-guid: d8b9b60d2abf409ca9dd2ce00506ac79
-timeCreated: 1682046644
\ No newline at end of file
diff --git a/Assets/GameScripts/HotFix/GameLogic/Network/MsgDispatcher.cs b/Assets/GameScripts/HotFix/GameLogic/Network/MsgDispatcher.cs
new file mode 100644
index 00000000..688d35ec
--- /dev/null
+++ b/Assets/GameScripts/HotFix/GameLogic/Network/MsgDispatcher.cs
@@ -0,0 +1,264 @@
+using System;
+using System.Collections.Generic;
+using GameProto;
+using TEngine;
+using CSPkg = GameProto.CSPkg;
+
+namespace GameLogic
+{
+ internal class MsgHandleDataToRmv
+ {
+ public uint m_msgCmd;
+ public CsMsgDelegate m_handle;
+ };
+
+ class MsgDispatcher
+ {
+ const int CHECK_TIMEOUT_PERFRAME = 10;
+ const int MAX_MSG_HANDLE = 256;
+
+ CsMsgDelegate[] m_aMsgHandles = new CsMsgDelegate[MAX_MSG_HANDLE];
+ float[] m_fMsgRegTime = new float[MAX_MSG_HANDLE];
+ UInt32[] m_adwMsgRegSeq = new UInt32[MAX_MSG_HANDLE]; //因为m_aMsgHandles存储的是hash,不能保证一定seqid一样,所以这儿存储下,用来校验
+ private uint[] m_aiMsgRegResCmdID = new uint[MAX_MSG_HANDLE];
+
+ UInt32 m_dwLastCheckIndex = 0;
+
+ Dictionary> m_mapCmdHandle = new Dictionary>();
+ List m_listStatHandle = new List();
+
+ //防止在处理消息的时候又删除了消息映射,所以这儿加了个队列来做个保护
+ private List m_rmvList = new List();
+ private bool m_isInHandleLoop = false;
+
+ private float m_timeout = 5;
+
+ // 清理所有的网络消息
+ public void CleanAllNetMsg()
+ {
+ m_mapCmdHandle.Clear();
+ }
+
+ public void SetTimeout(float timeout)
+ {
+ m_timeout = timeout;
+ }
+
+ public void RegSeqHandle(UInt32 dwMsgSeqID, uint iResCmdID, CsMsgDelegate msgDelegate)
+ {
+ UInt32 hashIndex = dwMsgSeqID % MAX_MSG_HANDLE;
+ if (m_aMsgHandles[hashIndex] != null)
+ {
+ OnCallSeqHandle(m_adwMsgRegSeq[hashIndex], m_aiMsgRegResCmdID[hashIndex]);
+ NotifyTimeout(m_aMsgHandles[hashIndex]);
+ RmvReg((int)hashIndex);
+ }
+
+ m_aMsgHandles[hashIndex] = msgDelegate;
+ m_fMsgRegTime[hashIndex] = NowTime;
+ m_adwMsgRegSeq[hashIndex] = dwMsgSeqID;
+ m_aiMsgRegResCmdID[hashIndex] = iResCmdID;
+ }
+
+ public void RegCmdHandle(uint iCmdID, CsMsgDelegate msgDelegate)
+ {
+ List listHandle;
+ if (!m_mapCmdHandle.TryGetValue(iCmdID, out listHandle))
+ {
+ listHandle = new List();
+ m_mapCmdHandle[iCmdID] = listHandle;
+ }
+
+ if (listHandle != null)
+ {
+ if (listHandle.Contains(msgDelegate))
+ {
+ Log.Error("-------------repeat RegCmdHandle:{0}-----------", iCmdID);
+ }
+
+ listHandle.Add(msgDelegate);
+ }
+ }
+
+ ///
+ /// 注册统计处理接口
+ ///
+ ///
+ public void RegCmdStatHandle(CsMsgStatDelegate handler)
+ {
+ m_listStatHandle.Add(handler);
+ }
+
+ public void DispatchCmdStat(int cmdID, int pkgSize)
+ {
+ foreach (CsMsgStatDelegate handle in m_listStatHandle)
+ {
+ handle(cmdID, pkgSize);
+ }
+ }
+
+ public void RmvCmdHandle(uint iCmdID, CsMsgDelegate msgDelegate)
+ {
+ if (m_isInHandleLoop)
+ {
+ MsgHandleDataToRmv toRmvData = new MsgHandleDataToRmv();
+ toRmvData.m_msgCmd = iCmdID;
+ toRmvData.m_handle = msgDelegate;
+
+ m_rmvList.Add(toRmvData);
+ return;
+ }
+
+ List listHandle;
+ if (!m_mapCmdHandle.TryGetValue(iCmdID, out listHandle))
+ {
+ return;
+ }
+
+ if (listHandle != null)
+ {
+ listHandle.Remove(msgDelegate);
+ }
+ }
+
+ public void NotifyCmdError(uint iCmdID, CsMsgResult result)
+ {
+ NotifyCmdHandle(iCmdID, result, default(CSPkg));
+ }
+
+ protected bool NotifyCmdHandle(uint cmdID, CsMsgResult result, CSPkg pkg)
+ {
+ bool ret = false;
+ if (m_mapCmdHandle.TryGetValue(cmdID, out var listHandle))
+ {
+ m_isInHandleLoop = true;
+
+ var rmvList = m_rmvList;
+ rmvList.Clear();
+ foreach (CsMsgDelegate handle in listHandle)
+ {
+ ret = true;
+
+ TProfiler.BeginSample("handle");
+ handle(result, pkg);
+ TProfiler.EndSample();
+ }
+
+ m_isInHandleLoop = false;
+
+ //再统一删除掉
+ int rmvCnt = rmvList.Count;
+ for (int i = 0; i < rmvCnt; i++)
+ {
+ var rmvItem = rmvList[i];
+ Log.Error("-------------remove cmd handle on loop:{0}-----------", rmvItem.m_msgCmd);
+ RmvCmdHandle(rmvItem.m_msgCmd, rmvItem.m_handle);
+ }
+ }
+
+ return ret;
+ }
+
+ protected void OnCallSeqHandle(UInt32 echoSeq, uint resCmdID)
+ {
+ if (echoSeq > 0)
+ {
+ // TODO
+ // GameEvent.Get().FinWaitUI(echoSeq);
+ }
+ }
+
+ protected void NotifyTimeout(CsMsgDelegate msgHandler)
+ {
+ msgHandler(CsMsgResult.MsgTimeOut, default(CSPkg));
+ }
+
+ public void NotifySeqError(UInt32 dwSeqID, CsMsgResult result)
+ {
+ UInt32 hashIndex = dwSeqID % MAX_MSG_HANDLE;
+
+ //先判断是否有注册的指定消息
+ if (m_aMsgHandles[hashIndex] != null &&
+ m_adwMsgRegSeq[hashIndex] == dwSeqID)
+ {
+ OnCallSeqHandle(dwSeqID, m_aiMsgRegResCmdID[hashIndex]);
+ m_aMsgHandles[hashIndex](result, null);
+
+ RmvReg((int)hashIndex);
+ }
+ }
+
+ public bool IsCmdFilterNoLog(int cmdID)
+ {
+ // TODO
+ /*switch (cmdID)
+ {
+ case netMacros.CS_CMD_HEATBEAT_RES:
+ return true;
+ default:
+ break;
+ }*/
+
+ return false;
+ }
+
+ public void NotifyMsg(CSPkg msg)
+ {
+ UInt32 dwSeq = msg.Head.Echo;
+ UInt32 hashIndex = dwSeq % MAX_MSG_HANDLE;
+ //判断是否有固定的消息处理流程
+ bool bHaveHandle = NotifyCmdHandle(msg.Head.MsgId, CsMsgResult.NoError, msg);
+
+ //再判断是否有注册的指定消息
+ if (m_aMsgHandles[hashIndex] != null &&
+ m_adwMsgRegSeq[hashIndex] == dwSeq &&
+ m_aiMsgRegResCmdID[hashIndex] == (int)msg.Head.MsgId)
+ {
+ OnCallSeqHandle(m_adwMsgRegSeq[hashIndex], m_aiMsgRegResCmdID[hashIndex]);
+ m_aMsgHandles[hashIndex](CsMsgResult.NoError, msg);
+ RmvReg((int)hashIndex);
+ bHaveHandle = true;
+ }
+
+ if (!bHaveHandle)
+ {
+ //todo..临时改为debug
+ Log.Debug("there is no handle for Msg[{0}]", msg.Head.MsgId);
+ }
+ }
+
+ private float NowTime => GameTime.unscaledTime;
+
+ //定时检查是否请求超时了
+ public void Update()
+ {
+ float timeout = m_timeout;
+ float nowTime = NowTime;
+ 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] + timeout < nowTime)
+ {
+ Log.Error("msg timeout, resCmdID[{0}], reqSeq[{1}]", m_aiMsgRegResCmdID[m_dwLastCheckIndex],
+ m_adwMsgRegSeq[m_dwLastCheckIndex]);
+
+ OnCallSeqHandle(m_adwMsgRegSeq[m_dwLastCheckIndex], m_aiMsgRegResCmdID[m_dwLastCheckIndex]);
+ NotifyTimeout(m_aMsgHandles[m_dwLastCheckIndex]);
+
+ RmvReg((int)m_dwLastCheckIndex);
+ }
+ }
+ }
+ }
+
+ public void RmvReg(int index)
+ {
+ m_aMsgHandles[index] = null;
+ m_adwMsgRegSeq[index] = 0;
+ m_aiMsgRegResCmdID[index] = 0;
+ m_fMsgRegTime[index] = 0;
+ }
+ }
+}
\ No newline at end of file
diff --git a/Assets/GameScripts/HotFix/GameLogic/Network/MsgDispatcher.cs.meta b/Assets/GameScripts/HotFix/GameLogic/Network/MsgDispatcher.cs.meta
new file mode 100644
index 00000000..c9c8c3d4
--- /dev/null
+++ b/Assets/GameScripts/HotFix/GameLogic/Network/MsgDispatcher.cs.meta
@@ -0,0 +1,3 @@
+fileFormatVersion: 2
+guid: 7d667fb84fed4c5f93a06c464585512f
+timeCreated: 1684333223
\ No newline at end of file
diff --git a/Assets/GameScripts/HotFix/GameLogic/Network/NetworkChannelHelper.cs b/Assets/GameScripts/HotFix/GameLogic/Network/NetworkChannelHelper.cs
index 8f2a40ee..75d1f353 100644
--- a/Assets/GameScripts/HotFix/GameLogic/Network/NetworkChannelHelper.cs
+++ b/Assets/GameScripts/HotFix/GameLogic/Network/NetworkChannelHelper.cs
@@ -1,10 +1,9 @@
-using ProtoBuf;
-using ProtoBuf.Meta;
-using System;
+using System;
using System.Collections.Generic;
using System.IO;
using System.Net.Sockets;
using System.Reflection;
+using GameProto;
using TEngine;
namespace GameLogic
@@ -29,31 +28,6 @@ namespace GameLogic
{
_networkChannel = networkChannel;
- // 反射注册包和包处理函数。
- Type packetBaseType = typeof(ProtoPacket);
- Assembly assembly = Assembly.GetExecutingAssembly();
- Type[] types = assembly.GetTypes();
- for (int i = 0; i < types.Length; i++)
- {
- if (!types[i].IsClass || types[i].IsAbstract)
- {
- continue;
- }
-
- if (types[i].BaseType == packetBaseType)
- {
- PacketBase packetBase = (PacketBase)Activator.CreateInstance(types[i]);
- Type packetType = GetServerToClientPacketType(packetBase.Id);
- if (packetType != null)
- {
- Log.Warning("Already exist packet type '{0}', check '{1}' or '{2}'?.", packetBase.Id.ToString(), packetType.Name, packetBase.GetType().Name);
- continue;
- }
-
- _serverToClientPacketTypes.Add(packetBase.Id, types[i]);
- }
- }
-
GameEvent.AddEventListener(NetworkEvent.NetworkConnectedEvent, OnNetworkConnected);
GameEvent.AddEventListener(NetworkEvent.NetworkClosedEvent, OnNetworkClosed);
GameEvent.AddEventListener(NetworkEvent.NetworkMissHeartBeatEvent, OnNetworkMissHeartBeat);
@@ -84,13 +58,16 @@ namespace GameLogic
_networkChannel.Socket.SendBufferSize = 1024 * 64;
}
+ public CSPkg HeartBeatPack = new CSPkg { Head = new CSPkgHead(), Body = new CSPkgBody() };
+
///
/// 发送心跳消息包。
///
/// 是否发送心跳消息包成功。
public bool SendHeartBeat()
{
- _networkChannel.Send(MemoryPool.Acquire());
+ HeartBeatPack.Head.MsgId = (uint)CSMsgID.CsCmdHeatbeatReq;
+ _networkChannel.Send(HeartBeatPack);
return true;
}
@@ -101,10 +78,9 @@ namespace GameLogic
/// 要序列化的消息包。
/// 要序列化的目标流。
/// 是否序列化成功。
- public bool Serialize(T packet, Stream destination) where T : Packet
+ public bool Serialize(CSPkg packet, Stream destination)
{
- PacketBase packetImpl = packet as PacketBase;
- if (packetImpl == null)
+ if (packet == null)
{
Log.Warning("Packet is invalid.");
return false;
@@ -113,12 +89,7 @@ namespace GameLogic
_cachedStream.SetLength(_cachedStream.Capacity); // 此行防止 Array.Copy 的数据无法写入
_cachedStream.Position = 0L;
- PacketHeader packetHeader = MemoryPool.Acquire();
- Serializer.Serialize(_cachedStream, packetHeader);
- MemoryPool.Release(packetHeader);
-
- Serializer.SerializeWithLengthPrefix(_cachedStream, packet, PrefixStyle.Fixed32);
- MemoryPool.Release((IMemory)packet);
+ global::ProtobufUtility.ToStream(packet,destination);
_cachedStream.WriteTo(destination);
return true;
@@ -132,9 +103,10 @@ namespace GameLogic
/// 反序列化后的消息包头。
public IPacketHeader DeserializePacketHeader(Stream source, out object customErrorData)
{
+ // TODO
// 注意:此函数并不在主线程调用!
customErrorData = null;
- return (IPacketHeader)RuntimeTypeModel.Default.Deserialize(source, MemoryPool.Acquire(), typeof(PacketHeader));
+ return null; //(IPacketHeader)RuntimeTypeModel.Default.Deserialize(source, MemoryPool.Acquire(), typeof(PacketHeader));
}
///
@@ -144,7 +116,7 @@ namespace GameLogic
/// 要反序列化的来源流。
/// 用户自定义错误数据。
/// 反序列化后的消息包。
- public Packet DeserializePacket(IPacketHeader packetHeader, Stream source, out object customErrorData)
+ public CSPkg DeserializePacket(IPacketHeader packetHeader, Stream source, out object customErrorData)
{
// 注意:此函数并不在主线程调用!
customErrorData = null;
@@ -156,13 +128,13 @@ namespace GameLogic
return null;
}
- Packet packet = null;
+ CSPkg csPkg = null;
if (scPacketHeader.IsValid)
{
Type packetType = GetServerToClientPacketType(scPacketHeader.Id);
if (packetType != null)
{
- packet = (Packet)RuntimeTypeModel.Default.DeserializeWithLengthPrefix(source, MemoryPool.Acquire(packetType), packetType, PrefixStyle.Fixed32, 0);
+ csPkg = global::ProtobufUtility.Deserialize(((MemoryStream)source).GetBuffer());;
}
else
{
@@ -175,7 +147,7 @@ namespace GameLogic
}
MemoryPool.Release(scPacketHeader);
- return packet;
+ return csPkg;
}
private Type GetServerToClientPacketType(int id)
diff --git a/Assets/TEngine/Runtime/GameFramework/Network.meta b/Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore.meta
similarity index 100%
rename from Assets/TEngine/Runtime/GameFramework/Network.meta
rename to Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore.meta
diff --git a/Assets/TEngine/Runtime/GameFramework/Network/AddressFamily.cs b/Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/AddressFamily.cs
similarity index 100%
rename from Assets/TEngine/Runtime/GameFramework/Network/AddressFamily.cs
rename to Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/AddressFamily.cs
diff --git a/Assets/TEngine/Runtime/GameFramework/Network/AddressFamily.cs.meta b/Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/AddressFamily.cs.meta
similarity index 100%
rename from Assets/TEngine/Runtime/GameFramework/Network/AddressFamily.cs.meta
rename to Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/AddressFamily.cs.meta
diff --git a/Assets/TEngine/Runtime/GameFramework/Network/Interface.meta b/Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/Interface.meta
similarity index 100%
rename from Assets/TEngine/Runtime/GameFramework/Network/Interface.meta
rename to Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/Interface.meta
diff --git a/Assets/TEngine/Runtime/GameFramework/Network/Interface/INetworkChannel.cs b/Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/Interface/INetworkChannel.cs
similarity index 96%
rename from Assets/TEngine/Runtime/GameFramework/Network/Interface/INetworkChannel.cs
rename to Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/Interface/INetworkChannel.cs
index 6a37e12a..cf136411 100644
--- a/Assets/TEngine/Runtime/GameFramework/Network/Interface/INetworkChannel.cs
+++ b/Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/Interface/INetworkChannel.cs
@@ -1,6 +1,8 @@
using System;
using System.Net;
using System.Net.Sockets;
+using GameProto;
+using Google.Protobuf;
namespace TEngine
{
@@ -163,7 +165,7 @@ namespace TEngine
/// 消息包类型。
/// 要发送的消息包。
/// 消息包是否发送成功。
- bool Send(T packet) where T : Packet;
+ bool Send(CSPkg packet);
///
/// 向远程主机发送消息包并注册消息回调。
@@ -173,6 +175,6 @@ namespace TEngine
/// 要注册的回调。
/// 是否需要等待UI。
/// 消息包是否发送成功。
- bool Send(T packet, CsMsgDelegate resHandler, bool needShowWaitUI = false) where T : Packet;
+ bool Send(CSPkg packet, CsMsgDelegate resHandler, bool needShowWaitUI = false);
}
}
diff --git a/Assets/TEngine/Runtime/GameFramework/Network/Interface/INetworkChannel.cs.meta b/Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/Interface/INetworkChannel.cs.meta
similarity index 100%
rename from Assets/TEngine/Runtime/GameFramework/Network/Interface/INetworkChannel.cs.meta
rename to Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/Interface/INetworkChannel.cs.meta
diff --git a/Assets/TEngine/Runtime/GameFramework/Network/Interface/INetworkChannelHelper.cs b/Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/Interface/INetworkChannelHelper.cs
similarity index 92%
rename from Assets/TEngine/Runtime/GameFramework/Network/Interface/INetworkChannelHelper.cs
rename to Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/Interface/INetworkChannelHelper.cs
index 7853a5d3..ce850051 100644
--- a/Assets/TEngine/Runtime/GameFramework/Network/Interface/INetworkChannelHelper.cs
+++ b/Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/Interface/INetworkChannelHelper.cs
@@ -1,4 +1,5 @@
using System.IO;
+using GameProto;
namespace TEngine
{
@@ -44,7 +45,7 @@ namespace TEngine
/// 要序列化的消息包。
/// 要序列化的目标流。
/// 是否序列化成功。
- bool Serialize(T packet, Stream destination) where T : Packet;
+ bool Serialize(CSPkg packet, Stream destination);
///
/// 反序列化消息包头。
@@ -61,6 +62,6 @@ namespace TEngine
/// 要反序列化的来源流。
/// 用户自定义错误数据。
/// 反序列化后的消息包。
- Packet DeserializePacket(IPacketHeader packetHeader, Stream source, out object customErrorData);
+ CSPkg DeserializePacket(IPacketHeader packetHeader, Stream source, out object customErrorData);
}
}
diff --git a/Assets/TEngine/Runtime/GameFramework/Network/Interface/INetworkChannelHelper.cs.meta b/Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/Interface/INetworkChannelHelper.cs.meta
similarity index 100%
rename from Assets/TEngine/Runtime/GameFramework/Network/Interface/INetworkChannelHelper.cs.meta
rename to Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/Interface/INetworkChannelHelper.cs.meta
diff --git a/Assets/TEngine/Runtime/GameFramework/Network/Interface/INetworkManager.cs b/Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/Interface/INetworkManager.cs
similarity index 100%
rename from Assets/TEngine/Runtime/GameFramework/Network/Interface/INetworkManager.cs
rename to Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/Interface/INetworkManager.cs
diff --git a/Assets/TEngine/Runtime/GameFramework/Network/Interface/INetworkManager.cs.meta b/Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/Interface/INetworkManager.cs.meta
similarity index 100%
rename from Assets/TEngine/Runtime/GameFramework/Network/Interface/INetworkManager.cs.meta
rename to Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/Interface/INetworkManager.cs.meta
diff --git a/Assets/TEngine/Runtime/GameFramework/Network/Interface/IPacketHeader.cs b/Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/Interface/IPacketHeader.cs
similarity index 100%
rename from Assets/TEngine/Runtime/GameFramework/Network/Interface/IPacketHeader.cs
rename to Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/Interface/IPacketHeader.cs
diff --git a/Assets/TEngine/Runtime/GameFramework/Network/Interface/IPacketHeader.cs.meta b/Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/Interface/IPacketHeader.cs.meta
similarity index 100%
rename from Assets/TEngine/Runtime/GameFramework/Network/Interface/IPacketHeader.cs.meta
rename to Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/Interface/IPacketHeader.cs.meta
diff --git a/Assets/TEngine/Runtime/GameFramework/Network/Kcp.meta b/Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/Kcp.meta
similarity index 100%
rename from Assets/TEngine/Runtime/GameFramework/Network/Kcp.meta
rename to Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/Kcp.meta
diff --git a/Assets/TEngine/Runtime/GameFramework/Network/Kcp/Core.meta b/Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/Kcp/Core.meta
similarity index 100%
rename from Assets/TEngine/Runtime/GameFramework/Network/Kcp/Core.meta
rename to Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/Kcp/Core.meta
diff --git a/Assets/TEngine/Runtime/GameFramework/Network/Kcp/Core/FakeKcpIO.cs b/Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/Kcp/Core/FakeKcpIO.cs
similarity index 100%
rename from Assets/TEngine/Runtime/GameFramework/Network/Kcp/Core/FakeKcpIO.cs
rename to Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/Kcp/Core/FakeKcpIO.cs
diff --git a/Assets/TEngine/Runtime/GameFramework/Network/Kcp/Core/FakeKcpIO.cs.meta b/Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/Kcp/Core/FakeKcpIO.cs.meta
similarity index 100%
rename from Assets/TEngine/Runtime/GameFramework/Network/Kcp/Core/FakeKcpIO.cs.meta
rename to Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/Kcp/Core/FakeKcpIO.cs.meta
diff --git a/Assets/TEngine/Runtime/GameFramework/Network/Kcp/Core/IKcpInterface.cs b/Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/Kcp/Core/IKcpInterface.cs
similarity index 100%
rename from Assets/TEngine/Runtime/GameFramework/Network/Kcp/Core/IKcpInterface.cs
rename to Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/Kcp/Core/IKcpInterface.cs
diff --git a/Assets/TEngine/Runtime/GameFramework/Network/Kcp/Core/IKcpInterface.cs.meta b/Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/Kcp/Core/IKcpInterface.cs.meta
similarity index 100%
rename from Assets/TEngine/Runtime/GameFramework/Network/Kcp/Core/IKcpInterface.cs.meta
rename to Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/Kcp/Core/IKcpInterface.cs.meta
diff --git a/Assets/TEngine/Runtime/GameFramework/Network/Kcp/Core/IKcpSegment.cs b/Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/Kcp/Core/IKcpSegment.cs
similarity index 100%
rename from Assets/TEngine/Runtime/GameFramework/Network/Kcp/Core/IKcpSegment.cs
rename to Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/Kcp/Core/IKcpSegment.cs
diff --git a/Assets/TEngine/Runtime/GameFramework/Network/Kcp/Core/IKcpSegment.cs.meta b/Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/Kcp/Core/IKcpSegment.cs.meta
similarity index 100%
rename from Assets/TEngine/Runtime/GameFramework/Network/Kcp/Core/IKcpSegment.cs.meta
rename to Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/Kcp/Core/IKcpSegment.cs.meta
diff --git a/Assets/TEngine/Runtime/GameFramework/Network/Kcp/Core/Kcp.cs b/Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/Kcp/Core/Kcp.cs
similarity index 100%
rename from Assets/TEngine/Runtime/GameFramework/Network/Kcp/Core/Kcp.cs
rename to Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/Kcp/Core/Kcp.cs
diff --git a/Assets/TEngine/Runtime/GameFramework/Network/Kcp/Core/Kcp.cs.meta b/Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/Kcp/Core/Kcp.cs.meta
similarity index 100%
rename from Assets/TEngine/Runtime/GameFramework/Network/Kcp/Core/Kcp.cs.meta
rename to Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/Kcp/Core/Kcp.cs.meta
diff --git a/Assets/TEngine/Runtime/GameFramework/Network/Kcp/Core/KcpCore.cs b/Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/Kcp/Core/KcpCore.cs
similarity index 100%
rename from Assets/TEngine/Runtime/GameFramework/Network/Kcp/Core/KcpCore.cs
rename to Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/Kcp/Core/KcpCore.cs
diff --git a/Assets/TEngine/Runtime/GameFramework/Network/Kcp/Core/KcpCore.cs.meta b/Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/Kcp/Core/KcpCore.cs.meta
similarity index 100%
rename from Assets/TEngine/Runtime/GameFramework/Network/Kcp/Core/KcpCore.cs.meta
rename to Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/Kcp/Core/KcpCore.cs.meta
diff --git a/Assets/TEngine/Runtime/GameFramework/Network/Kcp/Core/KcpIO.cs b/Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/Kcp/Core/KcpIO.cs
similarity index 100%
rename from Assets/TEngine/Runtime/GameFramework/Network/Kcp/Core/KcpIO.cs
rename to Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/Kcp/Core/KcpIO.cs
diff --git a/Assets/TEngine/Runtime/GameFramework/Network/Kcp/Core/KcpIO.cs.meta b/Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/Kcp/Core/KcpIO.cs.meta
similarity index 100%
rename from Assets/TEngine/Runtime/GameFramework/Network/Kcp/Core/KcpIO.cs.meta
rename to Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/Kcp/Core/KcpIO.cs.meta
diff --git a/Assets/TEngine/Runtime/GameFramework/Network/Kcp/Core/KcpOutputWriter.cs b/Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/Kcp/Core/KcpOutputWriter.cs
similarity index 100%
rename from Assets/TEngine/Runtime/GameFramework/Network/Kcp/Core/KcpOutputWriter.cs
rename to Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/Kcp/Core/KcpOutputWriter.cs
diff --git a/Assets/TEngine/Runtime/GameFramework/Network/Kcp/Core/KcpOutputWriter.cs.meta b/Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/Kcp/Core/KcpOutputWriter.cs.meta
similarity index 100%
rename from Assets/TEngine/Runtime/GameFramework/Network/Kcp/Core/KcpOutputWriter.cs.meta
rename to Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/Kcp/Core/KcpOutputWriter.cs.meta
diff --git a/Assets/TEngine/Runtime/GameFramework/Network/Kcp/Core/KcpSegment.cs b/Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/Kcp/Core/KcpSegment.cs
similarity index 100%
rename from Assets/TEngine/Runtime/GameFramework/Network/Kcp/Core/KcpSegment.cs
rename to Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/Kcp/Core/KcpSegment.cs
diff --git a/Assets/TEngine/Runtime/GameFramework/Network/Kcp/Core/KcpSegment.cs.meta b/Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/Kcp/Core/KcpSegment.cs.meta
similarity index 100%
rename from Assets/TEngine/Runtime/GameFramework/Network/Kcp/Core/KcpSegment.cs.meta
rename to Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/Kcp/Core/KcpSegment.cs.meta
diff --git a/Assets/TEngine/Runtime/GameFramework/Network/Kcp/Core/KcpTrace.cs b/Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/Kcp/Core/KcpTrace.cs
similarity index 100%
rename from Assets/TEngine/Runtime/GameFramework/Network/Kcp/Core/KcpTrace.cs
rename to Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/Kcp/Core/KcpTrace.cs
diff --git a/Assets/TEngine/Runtime/GameFramework/Network/Kcp/Core/KcpTrace.cs.meta b/Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/Kcp/Core/KcpTrace.cs.meta
similarity index 100%
rename from Assets/TEngine/Runtime/GameFramework/Network/Kcp/Core/KcpTrace.cs.meta
rename to Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/Kcp/Core/KcpTrace.cs.meta
diff --git a/Assets/TEngine/Runtime/GameFramework/Network/Kcp/Core/SegManager.cs b/Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/Kcp/Core/SegManager.cs
similarity index 100%
rename from Assets/TEngine/Runtime/GameFramework/Network/Kcp/Core/SegManager.cs
rename to Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/Kcp/Core/SegManager.cs
diff --git a/Assets/TEngine/Runtime/GameFramework/Network/Kcp/Core/SegManager.cs.meta b/Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/Kcp/Core/SegManager.cs.meta
similarity index 100%
rename from Assets/TEngine/Runtime/GameFramework/Network/Kcp/Core/SegManager.cs.meta
rename to Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/Kcp/Core/SegManager.cs.meta
diff --git a/Assets/TEngine/Runtime/GameFramework/Network/Kcp/Core/SimpleKcpClient.cs b/Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/Kcp/Core/SimpleKcpClient.cs
similarity index 100%
rename from Assets/TEngine/Runtime/GameFramework/Network/Kcp/Core/SimpleKcpClient.cs
rename to Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/Kcp/Core/SimpleKcpClient.cs
diff --git a/Assets/TEngine/Runtime/GameFramework/Network/Kcp/Core/SimpleKcpClient.cs.meta b/Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/Kcp/Core/SimpleKcpClient.cs.meta
similarity index 100%
rename from Assets/TEngine/Runtime/GameFramework/Network/Kcp/Core/SimpleKcpClient.cs.meta
rename to Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/Kcp/Core/SimpleKcpClient.cs.meta
diff --git a/Assets/TEngine/Runtime/GameFramework/Network/Kcp/Core/SimpleKcpServer.cs b/Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/Kcp/Core/SimpleKcpServer.cs
similarity index 100%
rename from Assets/TEngine/Runtime/GameFramework/Network/Kcp/Core/SimpleKcpServer.cs
rename to Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/Kcp/Core/SimpleKcpServer.cs
diff --git a/Assets/TEngine/Runtime/GameFramework/Network/Kcp/Core/SimpleKcpServer.cs.meta b/Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/Kcp/Core/SimpleKcpServer.cs.meta
similarity index 100%
rename from Assets/TEngine/Runtime/GameFramework/Network/Kcp/Core/SimpleKcpServer.cs.meta
rename to Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/Kcp/Core/SimpleKcpServer.cs.meta
diff --git a/Assets/TEngine/Runtime/GameFramework/Network/Kcp/Core/Utility.cs b/Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/Kcp/Core/Utility.cs
similarity index 100%
rename from Assets/TEngine/Runtime/GameFramework/Network/Kcp/Core/Utility.cs
rename to Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/Kcp/Core/Utility.cs
diff --git a/Assets/TEngine/Runtime/GameFramework/Network/Kcp/Core/Utility.cs.meta b/Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/Kcp/Core/Utility.cs.meta
similarity index 100%
rename from Assets/TEngine/Runtime/GameFramework/Network/Kcp/Core/Utility.cs.meta
rename to Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/Kcp/Core/Utility.cs.meta
diff --git a/Assets/TEngine/Runtime/GameFramework/Network/Kcp/NetworkManager.KcpNetworkChannel.cs b/Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/Kcp/NetworkManager.KcpNetworkChannel.cs
similarity index 100%
rename from Assets/TEngine/Runtime/GameFramework/Network/Kcp/NetworkManager.KcpNetworkChannel.cs
rename to Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/Kcp/NetworkManager.KcpNetworkChannel.cs
diff --git a/Assets/TEngine/Runtime/GameFramework/Network/Kcp/NetworkManager.KcpNetworkChannel.cs.meta b/Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/Kcp/NetworkManager.KcpNetworkChannel.cs.meta
similarity index 100%
rename from Assets/TEngine/Runtime/GameFramework/Network/Kcp/NetworkManager.KcpNetworkChannel.cs.meta
rename to Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/Kcp/NetworkManager.KcpNetworkChannel.cs.meta
diff --git a/Assets/TEngine/Runtime/GameFramework/Network/NetUtil.cs b/Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/NetUtil.cs
similarity index 100%
rename from Assets/TEngine/Runtime/GameFramework/Network/NetUtil.cs
rename to Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/NetUtil.cs
diff --git a/Assets/TEngine/Runtime/GameFramework/Network/NetUtil.cs.meta b/Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/NetUtil.cs.meta
similarity index 100%
rename from Assets/TEngine/Runtime/GameFramework/Network/NetUtil.cs.meta
rename to Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/NetUtil.cs.meta
diff --git a/Assets/TEngine/Runtime/GameFramework/Network/Network.cs b/Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/Network.cs
similarity index 100%
rename from Assets/TEngine/Runtime/GameFramework/Network/Network.cs
rename to Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/Network.cs
diff --git a/Assets/TEngine/Runtime/GameFramework/Network/Network.cs.meta b/Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/Network.cs.meta
similarity index 100%
rename from Assets/TEngine/Runtime/GameFramework/Network/Network.cs.meta
rename to Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/Network.cs.meta
diff --git a/Assets/TEngine/Runtime/GameFramework/Network/NetworkErrorCode.cs b/Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/NetworkErrorCode.cs
similarity index 100%
rename from Assets/TEngine/Runtime/GameFramework/Network/NetworkErrorCode.cs
rename to Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/NetworkErrorCode.cs
diff --git a/Assets/TEngine/Runtime/GameFramework/Network/NetworkErrorCode.cs.meta b/Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/NetworkErrorCode.cs.meta
similarity index 100%
rename from Assets/TEngine/Runtime/GameFramework/Network/NetworkErrorCode.cs.meta
rename to Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/NetworkErrorCode.cs.meta
diff --git a/Assets/TEngine/Runtime/GameFramework/Network/NetworkEvent.cs b/Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/NetworkEvent.cs
similarity index 100%
rename from Assets/TEngine/Runtime/GameFramework/Network/NetworkEvent.cs
rename to Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/NetworkEvent.cs
diff --git a/Assets/TEngine/Runtime/GameFramework/Network/NetworkEvent.cs.meta b/Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/NetworkEvent.cs.meta
similarity index 100%
rename from Assets/TEngine/Runtime/GameFramework/Network/NetworkEvent.cs.meta
rename to Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/NetworkEvent.cs.meta
diff --git a/Assets/TEngine/Runtime/GameFramework/Network/NetworkManager.ConnectState.cs b/Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/NetworkManager.ConnectState.cs
similarity index 100%
rename from Assets/TEngine/Runtime/GameFramework/Network/NetworkManager.ConnectState.cs
rename to Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/NetworkManager.ConnectState.cs
diff --git a/Assets/TEngine/Runtime/GameFramework/Network/NetworkManager.ConnectState.cs.meta b/Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/NetworkManager.ConnectState.cs.meta
similarity index 100%
rename from Assets/TEngine/Runtime/GameFramework/Network/NetworkManager.ConnectState.cs.meta
rename to Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/NetworkManager.ConnectState.cs.meta
diff --git a/Assets/TEngine/Runtime/GameFramework/Network/NetworkManager.HeartBeatState.cs b/Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/NetworkManager.HeartBeatState.cs
similarity index 100%
rename from Assets/TEngine/Runtime/GameFramework/Network/NetworkManager.HeartBeatState.cs
rename to Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/NetworkManager.HeartBeatState.cs
diff --git a/Assets/TEngine/Runtime/GameFramework/Network/NetworkManager.HeartBeatState.cs.meta b/Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/NetworkManager.HeartBeatState.cs.meta
similarity index 100%
rename from Assets/TEngine/Runtime/GameFramework/Network/NetworkManager.HeartBeatState.cs.meta
rename to Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/NetworkManager.HeartBeatState.cs.meta
diff --git a/Assets/TEngine/Runtime/GameFramework/Network/NetworkManager.NetworkChannelBase.cs b/Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/NetworkManager.NetworkChannelBase.cs
similarity index 96%
rename from Assets/TEngine/Runtime/GameFramework/Network/NetworkManager.NetworkChannelBase.cs
rename to Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/NetworkManager.NetworkChannelBase.cs
index 61aac9ca..ea9a5937 100644
--- a/Assets/TEngine/Runtime/GameFramework/Network/NetworkManager.NetworkChannelBase.cs
+++ b/Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/NetworkManager.NetworkChannelBase.cs
@@ -2,6 +2,8 @@
using System.Collections.Generic;
using System.Net;
using System.Net.Sockets;
+using GameProto;
+using Google.Protobuf;
namespace TEngine
{
@@ -15,7 +17,7 @@ namespace TEngine
private const float DefaultHeartBeatInterval = 30f;
private readonly string _name;
- protected readonly Queue SendPacketPool;
+ protected readonly Queue SendPacketPool;
protected readonly INetworkChannelHelper NetworkChannelHelper;
protected AddressFamily MAddressFamily;
protected bool MResetHeartBeatElapseSecondsWhenReceivePacket;
@@ -48,7 +50,7 @@ namespace TEngine
///
/// 消息包缓存堆栈。
///
- private readonly Queue _packsQueue = new Queue();
+ private readonly Queue _packsQueue = new Queue();
///
/// 初始化网络频道基类的新实例。
@@ -58,7 +60,7 @@ namespace TEngine
public NetworkChannelBase(string name, INetworkChannelHelper networkChannelHelper)
{
_name = name ?? string.Empty;
- SendPacketPool = new Queue();
+ SendPacketPool = new Queue();
NetworkChannelHelper = networkChannelHelper;
MAddressFamily = AddressFamily.Unknown;
MResetHeartBeatElapseSecondsWhenReceivePacket = false;
@@ -411,9 +413,8 @@ namespace TEngine
///
/// 向远程主机发送消息包。
///
- /// 消息包类型。
/// 要发送的消息包。
- public bool Send(T packet) where T : Packet
+ public bool Send(CSPkg packet)
{
if (MSocket == null)
{
@@ -466,9 +467,9 @@ namespace TEngine
/// 要注册的回调。
/// 是否需要等待UI。
/// 消息包是否发送成功。
- public bool Send(T packet, CsMsgDelegate resHandler, bool needShowWaitUI = false) where T : Packet
+ public bool Send(CSPkg packet, CsMsgDelegate resHandler, bool needShowWaitUI = false)
{
- RegisterMsgHandler(packet.Id,resHandler,false);
+ RegisterMsgHandler((int)packet.Head.MsgId,resHandler,false);
return Send(packet);
}
@@ -511,16 +512,16 @@ namespace TEngine
while (SendPacketPool.Count > 0)
{
- Packet packet = null;
+ CSPkg csPkg = null;
lock (SendPacketPool)
{
- packet = SendPacketPool.Dequeue();
+ csPkg = SendPacketPool.Dequeue();
}
bool serializeResult = false;
try
{
- serializeResult = NetworkChannelHelper.Serialize(packet, MSendState.Stream);
+ serializeResult = NetworkChannelHelper.Serialize(csPkg, MSendState.Stream);
}
catch (Exception exception)
{
@@ -614,22 +615,22 @@ namespace TEngine
try
{
- Packet packet = NetworkChannelHelper.DeserializePacket(MReceiveState.PacketHeader, MReceiveState.Stream, out var customErrorData);
+ CSPkg csPkg = NetworkChannelHelper.DeserializePacket(MReceiveState.PacketHeader, MReceiveState.Stream, out var customErrorData);
if (customErrorData != null && NetworkChannelCustomError != null)
{
NetworkChannelCustomError(this, customErrorData);
}
- if (packet != null)
+ if (csPkg != null)
{
lock (_cacheHandlerQueue)
{
- if (_msgHandlerMap.TryGetValue((int)packet.Id, out var listHandle))
+ if (_msgHandlerMap.TryGetValue((int)csPkg.Head.MsgId, out var listHandle))
{
_cacheHandlerQueue.Enqueue(listHandle);
- _packsQueue.Enqueue(packet);
+ _packsQueue.Enqueue(csPkg);
}
}
}
diff --git a/Assets/TEngine/Runtime/GameFramework/Network/NetworkManager.NetworkChannelBase.cs.meta b/Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/NetworkManager.NetworkChannelBase.cs.meta
similarity index 100%
rename from Assets/TEngine/Runtime/GameFramework/Network/NetworkManager.NetworkChannelBase.cs.meta
rename to Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/NetworkManager.NetworkChannelBase.cs.meta
diff --git a/Assets/TEngine/Runtime/GameFramework/Network/NetworkManager.ReceiveState.cs b/Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/NetworkManager.ReceiveState.cs
similarity index 100%
rename from Assets/TEngine/Runtime/GameFramework/Network/NetworkManager.ReceiveState.cs
rename to Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/NetworkManager.ReceiveState.cs
diff --git a/Assets/TEngine/Runtime/GameFramework/Network/NetworkManager.ReceiveState.cs.meta b/Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/NetworkManager.ReceiveState.cs.meta
similarity index 100%
rename from Assets/TEngine/Runtime/GameFramework/Network/NetworkManager.ReceiveState.cs.meta
rename to Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/NetworkManager.ReceiveState.cs.meta
diff --git a/Assets/TEngine/Runtime/GameFramework/Network/NetworkManager.SendState.cs b/Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/NetworkManager.SendState.cs
similarity index 100%
rename from Assets/TEngine/Runtime/GameFramework/Network/NetworkManager.SendState.cs
rename to Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/NetworkManager.SendState.cs
diff --git a/Assets/TEngine/Runtime/GameFramework/Network/NetworkManager.SendState.cs.meta b/Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/NetworkManager.SendState.cs.meta
similarity index 100%
rename from Assets/TEngine/Runtime/GameFramework/Network/NetworkManager.SendState.cs.meta
rename to Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/NetworkManager.SendState.cs.meta
diff --git a/Assets/TEngine/Runtime/GameFramework/Network/NetworkManager.TcpNetworkChannel.cs b/Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/NetworkManager.TcpNetworkChannel.cs
similarity index 100%
rename from Assets/TEngine/Runtime/GameFramework/Network/NetworkManager.TcpNetworkChannel.cs
rename to Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/NetworkManager.TcpNetworkChannel.cs
diff --git a/Assets/TEngine/Runtime/GameFramework/Network/NetworkManager.TcpNetworkChannel.cs.meta b/Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/NetworkManager.TcpNetworkChannel.cs.meta
similarity index 100%
rename from Assets/TEngine/Runtime/GameFramework/Network/NetworkManager.TcpNetworkChannel.cs.meta
rename to Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/NetworkManager.TcpNetworkChannel.cs.meta
diff --git a/Assets/TEngine/Runtime/GameFramework/Network/NetworkManager.TcpWithSyncReceiveNetworkChannel.cs b/Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/NetworkManager.TcpWithSyncReceiveNetworkChannel.cs
similarity index 100%
rename from Assets/TEngine/Runtime/GameFramework/Network/NetworkManager.TcpWithSyncReceiveNetworkChannel.cs
rename to Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/NetworkManager.TcpWithSyncReceiveNetworkChannel.cs
diff --git a/Assets/TEngine/Runtime/GameFramework/Network/NetworkManager.TcpWithSyncReceiveNetworkChannel.cs.meta b/Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/NetworkManager.TcpWithSyncReceiveNetworkChannel.cs.meta
similarity index 100%
rename from Assets/TEngine/Runtime/GameFramework/Network/NetworkManager.TcpWithSyncReceiveNetworkChannel.cs.meta
rename to Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/NetworkManager.TcpWithSyncReceiveNetworkChannel.cs.meta
diff --git a/Assets/TEngine/Runtime/GameFramework/Network/NetworkManager.UdpNetworkChannel.cs b/Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/NetworkManager.UdpNetworkChannel.cs
similarity index 100%
rename from Assets/TEngine/Runtime/GameFramework/Network/NetworkManager.UdpNetworkChannel.cs
rename to Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/NetworkManager.UdpNetworkChannel.cs
diff --git a/Assets/TEngine/Runtime/GameFramework/Network/NetworkManager.UdpNetworkChannel.cs.meta b/Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/NetworkManager.UdpNetworkChannel.cs.meta
similarity index 100%
rename from Assets/TEngine/Runtime/GameFramework/Network/NetworkManager.UdpNetworkChannel.cs.meta
rename to Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/NetworkManager.UdpNetworkChannel.cs.meta
diff --git a/Assets/TEngine/Runtime/GameFramework/Network/NetworkManager.cs b/Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/NetworkManager.cs
similarity index 94%
rename from Assets/TEngine/Runtime/GameFramework/Network/NetworkManager.cs
rename to Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/NetworkManager.cs
index 098cef2c..025cfd06 100644
--- a/Assets/TEngine/Runtime/GameFramework/Network/NetworkManager.cs
+++ b/Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/NetworkManager.cs
@@ -1,21 +1,23 @@
using System;
using System.Collections.Generic;
using System.Net.Sockets;
+using GameBase;
+using GameProto;
namespace TEngine
{
///
/// 网络消息委托。
///
- public delegate void CsMsgDelegate(Packet packet);
-
+ public delegate void CsMsgDelegate(CSPkg csPkg);
+
///
/// 网络管理器。
///
- internal sealed partial class NetworkManager : GameFrameworkModule, INetworkManager
+ internal sealed partial class NetworkManager : Singleton, INetworkManager
{
private readonly Dictionary _networkChannels;
-
+
private Action _networkConnectedEventHandler;
private Action _networkClosedEventHandler;
private Action _networkMissHeartBeatEventHandler;
@@ -90,7 +92,7 @@ namespace TEngine
///
/// 逻辑流逝时间,以秒为单位。
/// 真实流逝时间,以秒为单位。
- internal override void Update(float elapseSeconds, float realElapseSeconds)
+ public void Update(float elapseSeconds, float realElapseSeconds)
{
foreach (KeyValuePair networkChannel in _networkChannels)
{
@@ -101,7 +103,7 @@ namespace TEngine
///
/// 关闭并清理网络管理器。
///
- internal override void Shutdown()
+ public void Shutdown()
{
foreach (KeyValuePair networkChannel in _networkChannels)
{
@@ -183,7 +185,8 @@ namespace TEngine
/// 网络服务类型。
/// 网络频道辅助器。
/// 要创建的网络频道。
- public INetworkChannel CreateNetworkChannel(string name, ServiceType serviceType, INetworkChannelHelper networkChannelHelper)
+ public INetworkChannel CreateNetworkChannel(string name, ServiceType serviceType,
+ INetworkChannelHelper networkChannelHelper)
{
if (networkChannelHelper == null)
{
@@ -197,7 +200,8 @@ namespace TEngine
if (HasNetworkChannel(name))
{
- throw new GameFrameworkException(Utility.Text.Format("Already exist network channel '{0}'.", name ?? string.Empty));
+ throw new GameFrameworkException(Utility.Text.Format("Already exist network channel '{0}'.",
+ name ?? string.Empty));
}
NetworkChannelBase networkChannel = null;
@@ -210,17 +214,18 @@ namespace TEngine
case ServiceType.TcpWithSyncReceive:
networkChannel = new TcpWithSyncReceiveNetworkChannel(name, networkChannelHelper);
break;
-
+
case ServiceType.Udp:
networkChannel = new UdpNetworkChannel(name, networkChannelHelper);
break;
-
+
case ServiceType.Kcp:
networkChannel = new KcpNetworkChannel(name, networkChannelHelper);
break;
default:
- throw new GameFrameworkException(Utility.Text.Format("Not supported service type '{0}'.", serviceType));
+ throw new GameFrameworkException(Utility.Text.Format("Not supported service type '{0}'.",
+ serviceType));
}
networkChannel.NetworkChannelConnected += OnNetworkChannelConnected;
@@ -249,6 +254,7 @@ namespace TEngine
networkChannel.Shutdown();
return name != null && _networkChannels.Remove(name);
}
+
return false;
}
@@ -285,7 +291,8 @@ namespace TEngine
}
}
- private void OnNetworkChannelError(NetworkChannelBase networkChannel, NetworkErrorCode errorCode, SocketError socketErrorCode, string errorMessage)
+ private void OnNetworkChannelError(NetworkChannelBase networkChannel, NetworkErrorCode errorCode,
+ SocketError socketErrorCode, string errorMessage)
{
if (_networkErrorEventHandler != null)
{
@@ -307,4 +314,4 @@ namespace TEngine
}
}
}
-}
+}
\ No newline at end of file
diff --git a/Assets/TEngine/Runtime/GameFramework/Network/NetworkManager.cs.meta b/Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/NetworkManager.cs.meta
similarity index 100%
rename from Assets/TEngine/Runtime/GameFramework/Network/NetworkManager.cs.meta
rename to Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/NetworkManager.cs.meta
diff --git a/Assets/TEngine/Runtime/GameFramework/Network/ServiceType.cs b/Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/ServiceType.cs
similarity index 100%
rename from Assets/TEngine/Runtime/GameFramework/Network/ServiceType.cs
rename to Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/ServiceType.cs
diff --git a/Assets/TEngine/Runtime/GameFramework/Network/ServiceType.cs.meta b/Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/ServiceType.cs.meta
similarity index 100%
rename from Assets/TEngine/Runtime/GameFramework/Network/ServiceType.cs.meta
rename to Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/ServiceType.cs.meta
diff --git a/Assets/GameScripts/HotFix/GameLogic/Network/PacketBase.cs b/Assets/GameScripts/HotFix/GameLogic/Network/PacketBase.cs
deleted file mode 100644
index 0f66dbc4..00000000
--- a/Assets/GameScripts/HotFix/GameLogic/Network/PacketBase.cs
+++ /dev/null
@@ -1,24 +0,0 @@
-using TEngine;
-
-namespace GameLogic
-{
- ///
- /// 网络消息包基类。
- ///
- public abstract class PacketBase : Packet
- {
- ///
- /// 网络消息包Id。
- ///
- public int ProtoId;
-
- ///
- /// 网络消息包包体。
- ///
- public byte[] ProtoBody;
-
- public void Close()
- {
- }
- }
-}
\ No newline at end of file
diff --git a/Assets/GameScripts/HotFix/GameLogic/Network/PacketBase.cs.meta b/Assets/GameScripts/HotFix/GameLogic/Network/PacketBase.cs.meta
deleted file mode 100644
index 2db1a1bf..00000000
--- a/Assets/GameScripts/HotFix/GameLogic/Network/PacketBase.cs.meta
+++ /dev/null
@@ -1,3 +0,0 @@
-fileFormatVersion: 2
-guid: acea4283f57644b6b4452354d23f2803
-timeCreated: 1682045887
\ No newline at end of file
diff --git a/Assets/GameScripts/HotFix/GameLogic/Network/ProtoPacket.cs b/Assets/GameScripts/HotFix/GameLogic/Network/ProtoPacket.cs
deleted file mode 100644
index a7270f2c..00000000
--- a/Assets/GameScripts/HotFix/GameLogic/Network/ProtoPacket.cs
+++ /dev/null
@@ -1,15 +0,0 @@
-namespace GameLogic
-{
- ///
- /// 网络消息包。
- ///
- public partial class ProtoPacket : PacketBase
- {
- public override int Id => 1;
-
- public override void Clear()
- {
- Close();
- }
- }
-}
diff --git a/Assets/GameScripts/HotFix/GameLogic/Network/ProtoPacket.cs.meta b/Assets/GameScripts/HotFix/GameLogic/Network/ProtoPacket.cs.meta
deleted file mode 100644
index 17a8736e..00000000
--- a/Assets/GameScripts/HotFix/GameLogic/Network/ProtoPacket.cs.meta
+++ /dev/null
@@ -1,3 +0,0 @@
-fileFormatVersion: 2
-guid: da70995486db4799baba570b1767ab86
-timeCreated: 1682045865
\ No newline at end of file
diff --git a/Assets/GameScripts/HotFix/GameLogic/Network/ProtobufUtility.cs b/Assets/GameScripts/HotFix/GameLogic/Network/ProtobufUtility.cs
index 76825c17..d90653f3 100644
--- a/Assets/GameScripts/HotFix/GameLogic/Network/ProtobufUtility.cs
+++ b/Assets/GameScripts/HotFix/GameLogic/Network/ProtobufUtility.cs
@@ -18,6 +18,16 @@ public partial class ProtobufUtility
{
((IMessage)message).WriteTo(stream);
}
+
+ ///
+ /// 消息压入内存流。
+ ///
+ ///
+ ///
+ public static void ToStream(object message, Stream stream)
+ {
+ ((IMessage)message).WriteTo(stream);
+ }
///
/// 比特流解析。
diff --git a/Assets/GameScripts/HotFix/GameLogic/Network/ProtobufUtils.cs.meta b/Assets/GameScripts/HotFix/GameLogic/Network/ProtobufUtils.cs.meta
index 400e157c..d22d6e14 100644
--- a/Assets/GameScripts/HotFix/GameLogic/Network/ProtobufUtils.cs.meta
+++ b/Assets/GameScripts/HotFix/GameLogic/Network/ProtobufUtils.cs.meta
@@ -1,3 +1,3 @@
fileFormatVersion: 2
-guid: 972ca4545003463d8710de956f0fde66
+guid: 26e2c268a764bad4eb7412ad65f822e2
timeCreated: 1682047511
\ No newline at end of file
diff --git a/Assets/TEngine/Runtime/GameFramework/Network/Packet.cs b/Assets/TEngine/Runtime/GameFramework/Network/Packet.cs
deleted file mode 100644
index abae2275..00000000
--- a/Assets/TEngine/Runtime/GameFramework/Network/Packet.cs
+++ /dev/null
@@ -1,18 +0,0 @@
-namespace TEngine
-{
- ///
- /// 网络消息包基类。
- ///
- public abstract class Packet : IMemory
- {
- ///
- /// 获取类型编号。
- ///
- public abstract int Id { get; }
-
- ///
- /// 清理引用。
- ///
- public abstract void Clear();
- }
-}
\ No newline at end of file
diff --git a/Assets/TEngine/Runtime/GameFramework/Network/Packet.cs.meta b/Assets/TEngine/Runtime/GameFramework/Network/Packet.cs.meta
deleted file mode 100644
index 1aabb55e..00000000
--- a/Assets/TEngine/Runtime/GameFramework/Network/Packet.cs.meta
+++ /dev/null
@@ -1,3 +0,0 @@
-fileFormatVersion: 2
-guid: b840df90fc73484d94cf06e87190f9e2
-timeCreated: 1681994166
\ No newline at end of file