modify
This commit is contained in:
parent
4ee13da099
commit
ad8b67acb4
@ -1,17 +1,17 @@
|
||||
using AlicizaX.Editor;
|
||||
using System;
|
||||
using AlicizaX.Editor;
|
||||
using AlicizaX.Network.Runtime;
|
||||
using UnityEditor;
|
||||
|
||||
namespace AlicizaX.Network.Editor
|
||||
{
|
||||
[CustomEditor(typeof(NetworkComponent))]
|
||||
internal sealed class NetworkComponentInspector : ComponentTypeComponentInspector
|
||||
internal sealed class NetworkComponentInspector : GameFrameworkInspector
|
||||
{
|
||||
private SerializedProperty m_HeartInterval = null;
|
||||
|
||||
protected override void Enable()
|
||||
private void OnEnable()
|
||||
{
|
||||
base.Enable();
|
||||
m_HeartInterval = serializedObject.FindProperty("m_HeartInterval");
|
||||
}
|
||||
|
||||
@ -30,10 +30,5 @@ namespace AlicizaX.Network.Editor
|
||||
EditorGUI.EndDisabledGroup();
|
||||
Repaint();
|
||||
}
|
||||
|
||||
protected override void RefreshTypeNames()
|
||||
{
|
||||
RefreshComponentTypeNames(typeof(INetworkManager));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ using Fantasy.Network.Interface;
|
||||
|
||||
namespace AlicizaX.Network.Runtime
|
||||
{
|
||||
public interface INetworkManager : IModule
|
||||
public interface INetworkModule : IModule
|
||||
{
|
||||
public EConnectState ConnectState { get; }
|
||||
void SetHeartInterval(int heartInterval);
|
@ -10,52 +10,22 @@ namespace AlicizaX.Network.Runtime
|
||||
[DisallowMultipleComponent]
|
||||
[AddComponentMenu("Game Framework/Network")]
|
||||
[Preserve]
|
||||
public sealed class NetworkComponent : GameFrameworkComponent
|
||||
public sealed class NetworkComponent : MonoBehaviour
|
||||
{
|
||||
private INetworkManager _networkManager;
|
||||
private INetworkModule _networkModule;
|
||||
|
||||
[SerializeField] private int m_HeartInterval = 2000;
|
||||
|
||||
public EConnectState ConnectState => _networkManager.ConnectState;
|
||||
|
||||
protected override void Awake()
|
||||
private void Awake()
|
||||
{
|
||||
ImplementationComponentType = Utility.Assembly.GetType(componentType);
|
||||
InterfaceComponentType = typeof(INetworkManager);
|
||||
base.Awake();
|
||||
_networkManager = SysModuleCenter.GetModule<INetworkManager>();
|
||||
if (_networkManager == null)
|
||||
_networkModule = ModuleSystem.RegisterModule<INetworkModule>(typeof(NetworkModule));
|
||||
if (_networkModule == null)
|
||||
{
|
||||
Log.Fatal("Network Manager is invalid.");
|
||||
return;
|
||||
}
|
||||
|
||||
_networkManager.SetHeartInterval(m_HeartInterval);
|
||||
}
|
||||
|
||||
public async UniTask Initialize(params System.Reflection.Assembly[] assemblies)
|
||||
{
|
||||
await _networkManager.Initialize(assemblies);
|
||||
}
|
||||
|
||||
public void Connect(string remoteAddress, NetworkProtocolType networkProtocolType, bool isHttps)
|
||||
{
|
||||
_networkManager.Connect(remoteAddress, networkProtocolType, isHttps);
|
||||
}
|
||||
|
||||
public async UniTask<T> Call<T>(IRequest request, long routeId = 0) where T : IResponse
|
||||
{
|
||||
return await _networkManager.Call<T>(request, routeId);
|
||||
}
|
||||
|
||||
public void Send(IMessage message, uint rpcId = 0, long routeId = 0)
|
||||
{
|
||||
_networkManager.Send(message, rpcId, routeId);
|
||||
}
|
||||
|
||||
public void Send(IRouteMessage routeMessage, uint rpcId = 0, long routeId = 0)
|
||||
{
|
||||
_networkManager.Send(routeMessage, rpcId, routeId);
|
||||
_networkModule.SetHeartInterval(m_HeartInterval);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ using Log = AlicizaX.Runtime.Log;
|
||||
namespace AlicizaX.Network.Runtime
|
||||
{
|
||||
[UnityEngine.Scripting.Preserve]
|
||||
internal sealed class NetworkManager : INetworkManager
|
||||
internal sealed class NetworkModule : INetworkModule
|
||||
{
|
||||
private Scene _scene;
|
||||
private Session _session;
|
||||
@ -38,7 +38,7 @@ namespace AlicizaX.Network.Runtime
|
||||
allAssemblies[i] = assemblies[i];
|
||||
}
|
||||
|
||||
allAssemblies[allAssemblies.Length - 1] = typeof(NetworkManager).Assembly;
|
||||
allAssemblies[allAssemblies.Length - 1] = typeof(NetworkModule).Assembly;
|
||||
|
||||
await Fantasy.Platform.Unity.Entry.Initialize(allAssemblies);
|
||||
_scene = await Scene.Create(SceneRuntimeType.MainThread);
|
Loading…
Reference in New Issue
Block a user