From b15f51631ad80a92f41eaeb97d866f400e0b6a6b Mon Sep 17 00:00:00 2001 From: ALEXTANG <574809918@qq.com> Date: Sat, 20 May 2023 11:10:46 +0800 Subject: [PATCH] Update Network.cs --- .../GameLogic/Network/NetworkCore/Network.cs | 28 ++++++++++--------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/Network.cs b/Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/Network.cs index 887cf0d5..700184e8 100644 --- a/Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/Network.cs +++ b/Assets/GameScripts/HotFix/GameLogic/Network/NetworkCore/Network.cs @@ -1,6 +1,6 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.Net.Sockets; +using GameBase; using UnityEngine; namespace TEngine @@ -9,9 +9,9 @@ namespace TEngine /// 网络组件。 /// [DisallowMultipleComponent] - public sealed class Network : GameFrameworkModuleBase + public sealed class Network : UnitySingleton { - private static NetworkManager m_NetworkManager = null; + private NetworkManager m_NetworkManager = null; /// /// 获取网络频道数量。 @@ -21,7 +21,7 @@ namespace TEngine /// /// 游戏框架组件初始化。 /// - protected override void Awake() + public override void Awake() { base.Awake(); @@ -50,7 +50,7 @@ namespace TEngine /// /// 网络频道名称。 /// 是否存在网络频道。 - public static bool HasNetworkChannel(string name) + public bool HasNetworkChannel(string name) { return m_NetworkManager.HasNetworkChannel(name); } @@ -60,7 +60,7 @@ namespace TEngine /// /// 网络频道名称。 /// 要获取的网络频道。 - public static INetworkChannel GetNetworkChannel(string name) + public INetworkChannel GetNetworkChannel(string name) { return m_NetworkManager.GetNetworkChannel(name); } @@ -69,11 +69,11 @@ namespace TEngine /// 获取所有网络频道。 /// /// 所有网络频道。 - public static INetworkChannel[] StaticGetAllNetworkChannels() + public INetworkChannel[] StaticGetAllNetworkChannels() { return m_NetworkManager.GetAllNetworkChannels(); } - + /// /// 获取所有网络频道。 /// @@ -87,7 +87,7 @@ namespace TEngine /// 获取所有网络频道。 /// /// 所有网络频道。 - public static void GetAllNetworkChannels(List results) + public void GetAllNetworkChannels(List results) { m_NetworkManager.GetAllNetworkChannels(results); } @@ -99,7 +99,8 @@ namespace TEngine /// 网络服务类型。 /// 网络频道辅助器。 /// 要创建的网络频道。 - public static INetworkChannel CreateNetworkChannel(string name, ServiceType serviceType, INetworkChannelHelper networkChannelHelper) + public INetworkChannel CreateNetworkChannel(string name, ServiceType serviceType, + INetworkChannelHelper networkChannelHelper) { return m_NetworkManager.CreateNetworkChannel(name, serviceType, networkChannelHelper); } @@ -109,7 +110,7 @@ namespace TEngine /// /// 网络频道名称。 /// 是否销毁网络频道成功。 - public static bool DestroyNetworkChannel(string channelName) + public bool DestroyNetworkChannel(string channelName) { return m_NetworkManager.DestroyNetworkChannel(channelName); } @@ -129,7 +130,8 @@ namespace TEngine GameEvent.Send(NetworkEvent.NetworkMissHeartBeatEvent, channel, missCount); } - private void OnNetworkError(INetworkChannel channel, NetworkErrorCode networkErrorCode, SocketError socketError, string errorMessage) + private void OnNetworkError(INetworkChannel channel, NetworkErrorCode networkErrorCode, SocketError socketError, + string errorMessage) { GameEvent.Send(NetworkEvent.NetworkErrorEvent, channel, networkErrorCode, socketError, errorMessage); }