com.alicizax.unity.network/Runtime/Manager/NetworkComponent.cs

32 lines
818 B
C#
Raw Permalink Normal View History

2025-03-24 13:17:26 +08:00
using AlicizaX;
2025-02-24 17:35:48 +08:00
using Cysharp.Threading.Tasks;
using Fantasy.Network;
2025-03-19 13:02:15 +08:00
using Fantasy.Network.Interface;
2025-02-24 17:35:48 +08:00
using UnityEngine;
using UnityEngine.Scripting;
namespace AlicizaX.Network.Runtime
{
[DisallowMultipleComponent]
[AddComponentMenu("Game Framework/Network")]
[Preserve]
2025-03-20 20:47:48 +08:00
public sealed class NetworkComponent : MonoBehaviour
2025-02-24 17:35:48 +08:00
{
2025-03-20 20:47:48 +08:00
private INetworkModule _networkModule;
2025-02-24 17:35:48 +08:00
2025-03-18 19:41:26 +08:00
[SerializeField] private int m_HeartInterval = 2000;
2025-03-20 20:47:48 +08:00
private void Awake()
2025-02-24 17:35:48 +08:00
{
2025-04-27 19:28:14 +08:00
_networkModule = ModuleSystem.RegisterModule<INetworkModule,NetworkModule>();
2025-03-20 20:47:48 +08:00
if (_networkModule == null)
2025-02-24 17:35:48 +08:00
{
2025-03-24 13:17:26 +08:00
Log.Error("Network Manager is invalid.");
2025-02-24 17:35:48 +08:00
return;
}
2025-03-18 19:41:26 +08:00
2025-03-20 20:47:48 +08:00
_networkModule.SetHeartInterval(m_HeartInterval);
2025-03-19 13:02:15 +08:00
}
2025-02-24 17:35:48 +08:00
}
}