mirror of
https://github.com/Alex-Rachel/TEngine.git
synced 2025-08-14 16:51:28 +00:00
[+] 接入ET8服务端
[+] 接入ET8服务端
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
using System;
|
||||
using System.Reflection;
|
||||
|
||||
namespace ET.Server
|
||||
{
|
||||
[ConsoleHandler(ConsoleMode.Robot)]
|
||||
public class RobotConsoleHandler: IConsoleHandler
|
||||
{
|
||||
public async ETTask Run(Fiber fiber, ModeContex contex, string content)
|
||||
{
|
||||
string[] ss = content.Split(" ");
|
||||
switch (ss[0])
|
||||
{
|
||||
case ConsoleMode.Robot:
|
||||
break;
|
||||
|
||||
case "Run":
|
||||
{
|
||||
int caseType = int.Parse(ss[1]);
|
||||
|
||||
try
|
||||
{
|
||||
RobotLog.Debug($"run case start: {caseType}");
|
||||
await EventSystem.Instance.Invoke<RobotInvokeArgs, ETTask>(caseType, new RobotInvokeArgs() { Fiber = fiber, Content = content });
|
||||
RobotLog.Debug($"run case finish: {caseType}");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
RobotLog.Debug($"run case error: {caseType}\n{e}");
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "RunAll":
|
||||
{
|
||||
FieldInfo[] fieldInfos = typeof (RobotCaseType).GetFields();
|
||||
foreach (FieldInfo fieldInfo in fieldInfos)
|
||||
{
|
||||
int caseType = (int)fieldInfo.GetValue(null);
|
||||
if (caseType > RobotCaseType.MaxCaseType)
|
||||
{
|
||||
RobotLog.Debug($"case > {RobotCaseType.MaxCaseType}: {caseType}");
|
||||
break;
|
||||
}
|
||||
try
|
||||
{
|
||||
RobotLog.Debug($"run case start: {caseType}");
|
||||
await EventSystem.Instance.Invoke<RobotInvokeArgs, ETTask>(caseType, new RobotInvokeArgs() { Fiber = fiber, Content = content});
|
||||
RobotLog.Debug($"---------run case finish: {caseType}");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
RobotLog.Debug($"run case error: {caseType}\n{e}");
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
await ETTask.CompletedTask;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user