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 AlicizaX.Network.Runtime;
|
||||||
using UnityEditor;
|
using UnityEditor;
|
||||||
|
|
||||||
namespace AlicizaX.Network.Editor
|
namespace AlicizaX.Network.Editor
|
||||||
{
|
{
|
||||||
[CustomEditor(typeof(NetworkComponent))]
|
[CustomEditor(typeof(NetworkComponent))]
|
||||||
internal sealed class NetworkComponentInspector : ComponentTypeComponentInspector
|
internal sealed class NetworkComponentInspector : GameFrameworkInspector
|
||||||
{
|
{
|
||||||
private SerializedProperty m_HeartInterval = null;
|
private SerializedProperty m_HeartInterval = null;
|
||||||
|
|
||||||
protected override void Enable()
|
private void OnEnable()
|
||||||
{
|
{
|
||||||
base.Enable();
|
|
||||||
m_HeartInterval = serializedObject.FindProperty("m_HeartInterval");
|
m_HeartInterval = serializedObject.FindProperty("m_HeartInterval");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -30,10 +30,5 @@ namespace AlicizaX.Network.Editor
|
|||||||
EditorGUI.EndDisabledGroup();
|
EditorGUI.EndDisabledGroup();
|
||||||
Repaint();
|
Repaint();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void RefreshTypeNames()
|
|
||||||
{
|
|
||||||
RefreshComponentTypeNames(typeof(INetworkManager));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@ using Fantasy.Network.Interface;
|
|||||||
|
|
||||||
namespace AlicizaX.Network.Runtime
|
namespace AlicizaX.Network.Runtime
|
||||||
{
|
{
|
||||||
public interface INetworkManager : IModule
|
public interface INetworkModule : IModule
|
||||||
{
|
{
|
||||||
public EConnectState ConnectState { get; }
|
public EConnectState ConnectState { get; }
|
||||||
void SetHeartInterval(int heartInterval);
|
void SetHeartInterval(int heartInterval);
|
@ -10,52 +10,22 @@ namespace AlicizaX.Network.Runtime
|
|||||||
[DisallowMultipleComponent]
|
[DisallowMultipleComponent]
|
||||||
[AddComponentMenu("Game Framework/Network")]
|
[AddComponentMenu("Game Framework/Network")]
|
||||||
[Preserve]
|
[Preserve]
|
||||||
public sealed class NetworkComponent : GameFrameworkComponent
|
public sealed class NetworkComponent : MonoBehaviour
|
||||||
{
|
{
|
||||||
private INetworkManager _networkManager;
|
private INetworkModule _networkModule;
|
||||||
|
|
||||||
[SerializeField] private int m_HeartInterval = 2000;
|
[SerializeField] private int m_HeartInterval = 2000;
|
||||||
|
|
||||||
public EConnectState ConnectState => _networkManager.ConnectState;
|
private void Awake()
|
||||||
|
|
||||||
protected override void Awake()
|
|
||||||
{
|
{
|
||||||
ImplementationComponentType = Utility.Assembly.GetType(componentType);
|
_networkModule = ModuleSystem.RegisterModule<INetworkModule>(typeof(NetworkModule));
|
||||||
InterfaceComponentType = typeof(INetworkManager);
|
if (_networkModule == null)
|
||||||
base.Awake();
|
|
||||||
_networkManager = SysModuleCenter.GetModule<INetworkManager>();
|
|
||||||
if (_networkManager == null)
|
|
||||||
{
|
{
|
||||||
Log.Fatal("Network Manager is invalid.");
|
Log.Fatal("Network Manager is invalid.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_networkManager.SetHeartInterval(m_HeartInterval);
|
_networkModule.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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ using Log = AlicizaX.Runtime.Log;
|
|||||||
namespace AlicizaX.Network.Runtime
|
namespace AlicizaX.Network.Runtime
|
||||||
{
|
{
|
||||||
[UnityEngine.Scripting.Preserve]
|
[UnityEngine.Scripting.Preserve]
|
||||||
internal sealed class NetworkManager : INetworkManager
|
internal sealed class NetworkModule : INetworkModule
|
||||||
{
|
{
|
||||||
private Scene _scene;
|
private Scene _scene;
|
||||||
private Session _session;
|
private Session _session;
|
||||||
@ -38,7 +38,7 @@ namespace AlicizaX.Network.Runtime
|
|||||||
allAssemblies[i] = assemblies[i];
|
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);
|
await Fantasy.Platform.Unity.Entry.Initialize(allAssemblies);
|
||||||
_scene = await Scene.Create(SceneRuntimeType.MainThread);
|
_scene = await Scene.Create(SceneRuntimeType.MainThread);
|
Loading…
Reference in New Issue
Block a user