58 lines
1.6 KiB
C#
58 lines
1.6 KiB
C#
using EasyInject.Attributes;
|
|
using System.Collections.Generic;
|
|
using GameLogic.Origin.data;
|
|
using UnityEngine;
|
|
|
|
/// <summary>
|
|
/// 初始化网络流程
|
|
/// </summary>
|
|
[Component("InitNetWorkProcess")]
|
|
public class InitNetWorkProcess : IProcessState
|
|
{
|
|
[Autowired]
|
|
private NetWorkComponent netWorkComponent;
|
|
[Autowired("WcsWebSocket")]
|
|
private WcsWebSocket wcsWebSocket;
|
|
[Autowired("WmsStorageWebsocket")]
|
|
private WmsStorageWebsocket wmsStorageWebsocket;
|
|
private bool executing = false;
|
|
public string Name { get => "InitNetWorkProcess"; }
|
|
public int Priority { get => 0; }
|
|
public bool IsExecuteProcess { get => executing; set => executing = value; }
|
|
|
|
public void OnEnter()
|
|
{
|
|
Debug.Log("正在处理网络流程");
|
|
|
|
List<IWcsSocketDataHandle> wcsSocketDataHandles = ApplicationBoot.Instance.GetBeans<IWcsSocketDataHandle>();
|
|
wcsSocketDataHandles.ForEach(x =>
|
|
{
|
|
////监听后台数据变化
|
|
wcsWebSocket.OnMessage(x.GetChannleKey(), x.DataHandle);
|
|
});
|
|
|
|
List<IStorageSocketDataHandle> storageSocketDataHandles = ApplicationBoot.Instance.GetBeans<IStorageSocketDataHandle>();
|
|
storageSocketDataHandles.ForEach(v =>
|
|
{
|
|
////监听后台数据变化
|
|
wmsStorageWebsocket.OnMessage(v.DataHandle);
|
|
});
|
|
netWorkComponent?.ConnectAllWebSocket();
|
|
|
|
}
|
|
|
|
public void OnExit()
|
|
{
|
|
Debug.Log("网络服务启动完成");
|
|
IsExecuteProcess = false;
|
|
}
|
|
|
|
public void OnUpdate()
|
|
{
|
|
if (netWorkComponent.AllWebSocketConnected())
|
|
{
|
|
ApplicationStateMachine.Chanage(this);
|
|
}
|
|
}
|
|
}
|