mirror of
https://github.com/project-redbud/FunGame-Core.git
synced 2025-04-23 04:29:36 +08:00
修改一些变量的命名和注释
This commit is contained in:
parent
e131fc44f6
commit
9748f3138a
@ -24,10 +24,10 @@ namespace Milimoe.FunGame.Core.Library.Constant
|
||||
|
||||
public class SocketSet
|
||||
{
|
||||
public static int MaxRetryTimes { get; } = 20;
|
||||
public static int MaxConnection_1C2G { get; } = 10;
|
||||
public static int MaxConnection_General { get; } = 20;
|
||||
public static int MaxConnection_4C4G { get; } = 40;
|
||||
public const int MaxRetryTimes = 20;
|
||||
public const int MaxConnection_1C2G = 10;
|
||||
public const int MaxConnection_General = 20;
|
||||
public const int MaxConnection_4C4G = 40;
|
||||
|
||||
public const string Unknown = "Unknown";
|
||||
public const string Connect = "Connect";
|
||||
|
@ -9,16 +9,9 @@ namespace Milimoe.FunGame.Core.Library.Exception
|
||||
{
|
||||
public static class ExceptionHelper
|
||||
{
|
||||
public static string GetStackTrace(this System.Exception e)
|
||||
public static string GetErrorInfo(this System.Exception e)
|
||||
{
|
||||
if (e.Message != null && e.Message != "")
|
||||
{
|
||||
return $"ERROR: {e.Message}\n{e.StackTrace}";
|
||||
}
|
||||
else
|
||||
{
|
||||
return $"ERROR: \n{e.StackTrace}";
|
||||
}
|
||||
return (e.InnerException != null) ? $"InnerExceoption: {e.InnerException}\n{e}" : e.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -26,9 +26,9 @@ namespace Milimoe.FunGame.Core.Library.Exception
|
||||
e = new System.Exception(Name);
|
||||
}
|
||||
|
||||
public string GetStackTrace()
|
||||
public string GetErrorInfo()
|
||||
{
|
||||
return e.GetStackTrace();
|
||||
return e.GetErrorInfo();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ namespace Milimoe.FunGame.Core.Service
|
||||
/// <summary>
|
||||
/// 最大接受的线程数量
|
||||
/// </summary>
|
||||
private int MaxConnection { get; }
|
||||
private int MaxTask { get; }
|
||||
|
||||
/// <summary>
|
||||
/// 可参与高并发的字典,但添加效率较低
|
||||
@ -22,14 +22,14 @@ namespace Milimoe.FunGame.Core.Service
|
||||
/// <summary>
|
||||
/// Init ThreadManager
|
||||
/// </summary>
|
||||
/// <param name="MaxConnection">MaxConnection</param>
|
||||
internal ThreadManager(int MaxConnection = 0)
|
||||
/// <param name="MaxTask">MaxTask</param>
|
||||
internal ThreadManager(int MaxTask = 0)
|
||||
{
|
||||
if (MaxConnection <= 0)
|
||||
this.MaxConnection = Library.Constant.General.MaxTask_General;
|
||||
if (MaxTask <= 0)
|
||||
this.MaxTask = Library.Constant.General.MaxTask_General;
|
||||
else
|
||||
{
|
||||
this.MaxConnection = MaxConnection;
|
||||
this.MaxTask = MaxTask;
|
||||
}
|
||||
}
|
||||
|
||||
@ -54,7 +54,7 @@ namespace Milimoe.FunGame.Core.Service
|
||||
/// <returns>True:操作成功</returns>
|
||||
internal bool Add(string name, Task t)
|
||||
{
|
||||
if (Threads.Count + 1 > MaxConnection) return false;
|
||||
if (Threads.Count + 1 > MaxTask) return false;
|
||||
return Threads.TryAdd(name, t);
|
||||
}
|
||||
|
||||
|
@ -38,7 +38,7 @@ namespace Milimoe.FunGame.Desktop.Model
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Main?.GetMessage(e.GetStackTrace());
|
||||
Main?.GetMessage(e.GetErrorInfo());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -51,7 +51,7 @@ namespace Milimoe.FunGame.Desktop.Model
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Main?.GetMessage(e.GetStackTrace());
|
||||
Main?.GetMessage(e.GetErrorInfo());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -64,7 +64,7 @@ namespace Milimoe.FunGame.Desktop.Model
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Main?.GetMessage(e.GetStackTrace());
|
||||
Main?.GetMessage(e.GetErrorInfo());
|
||||
}
|
||||
}
|
||||
|
||||
@ -92,7 +92,7 @@ namespace Milimoe.FunGame.Desktop.Model
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Main?.GetMessage(e.GetStackTrace(), false);
|
||||
Main?.GetMessage(e.GetErrorInfo(), false);
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -160,7 +160,7 @@ namespace Milimoe.FunGame.Desktop.Model
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Main?.GetMessage(e.GetStackTrace(), false);
|
||||
Main?.GetMessage(e.GetErrorInfo(), false);
|
||||
}
|
||||
|
||||
return ConnectResult.ConnectFailed;
|
||||
@ -183,7 +183,7 @@ namespace Milimoe.FunGame.Desktop.Model
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Main.GetMessage(e.GetStackTrace(), false);
|
||||
Main.GetMessage(e.GetErrorInfo(), false);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@ -259,7 +259,7 @@ namespace Milimoe.FunGame.Desktop.Model
|
||||
catch (Exception e)
|
||||
{
|
||||
// 报错中断服务器连接
|
||||
Main?.GetMessage(e.GetStackTrace(), false);
|
||||
Main?.GetMessage(e.GetErrorInfo(), false);
|
||||
Main?.UpdateUI(MainControllerSet.Disconnected);
|
||||
Close();
|
||||
}
|
||||
@ -292,7 +292,7 @@ namespace Milimoe.FunGame.Desktop.Model
|
||||
// 返回的objs是该Login的User对象的各个属性
|
||||
if (objs.Length > 0) msg = (string)objs[0];
|
||||
Main?.GetMessage(msg);
|
||||
Main?.UpdateUI(MainControllerSet.SetUser, true, TimeType.TimeOnly, new object[] { Factory.New<User>(msg) });
|
||||
Main?.UpdateUI(MainControllerSet.SetUser, new object[] { Factory.New<User>(msg) });
|
||||
}
|
||||
|
||||
private void SocketHandle_Disconnect(object[] objs)
|
||||
|
@ -90,7 +90,7 @@ namespace Milimoe.FunGame.Desktop.UI
|
||||
/// <param name="time"></param>
|
||||
/// <param name="timetype"></param>
|
||||
/// <param name="objs"></param>
|
||||
public void UpdateUI(string? updatetype, bool time = true, TimeType timetype = TimeType.TimeOnly, object[]? objs = null)
|
||||
public void UpdateUI(string? updatetype, object[]? objs = null)
|
||||
{
|
||||
void action()
|
||||
{
|
||||
@ -164,16 +164,10 @@ namespace Milimoe.FunGame.Desktop.UI
|
||||
Thread.Sleep(5000);
|
||||
if (Others.Config.FunGame_isAutoRetry) MainController?.Do<object>(MainControllerSet.Connect); // 再次判断是否开启自动重连
|
||||
});
|
||||
if (time)
|
||||
WritelnGameInfo(DateTimeUtility.GetDateTimeToString(timetype) + "\n连接服务器失败,5秒后自动尝试重连。");
|
||||
else
|
||||
WritelnGameInfo("连接服务器失败,5秒后自动尝试重连。");
|
||||
WritelnSystemInfo("连接服务器失败,5秒后自动尝试重连。");
|
||||
}
|
||||
else
|
||||
if (time)
|
||||
WritelnGameInfo(DateTimeUtility.GetDateTimeToString(timetype) + "\n无法连接至服务器,请检查你的网络连接。");
|
||||
else
|
||||
WritelnGameInfo("无法连接至服务器,请检查你的网络连接。");
|
||||
WritelnSystemInfo("无法连接至服务器,请检查你的网络连接。");
|
||||
break;
|
||||
|
||||
case Others.MainControllerSet.Disconnect:
|
||||
@ -235,7 +229,7 @@ namespace Milimoe.FunGame.Desktop.UI
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
WritelnGameInfo(e.GetStackTrace());
|
||||
WritelnGameInfo(e.GetErrorInfo());
|
||||
UpdateUI(Others.MainControllerSet.SetRed);
|
||||
}
|
||||
}
|
||||
@ -260,7 +254,7 @@ namespace Milimoe.FunGame.Desktop.UI
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
WritelnGameInfo(e.GetStackTrace());
|
||||
WritelnGameInfo(e.GetErrorInfo());
|
||||
}
|
||||
};
|
||||
InvokeUpdateUI(action);
|
||||
@ -307,7 +301,7 @@ namespace Milimoe.FunGame.Desktop.UI
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
WritelnGameInfo(e.GetStackTrace());
|
||||
WritelnGameInfo(e.GetErrorInfo());
|
||||
}
|
||||
}
|
||||
|
||||
@ -377,6 +371,16 @@ namespace Milimoe.FunGame.Desktop.UI
|
||||
GameInfo.ScrollToCaret();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 向消息队列输出一行系统信息
|
||||
/// </summary>
|
||||
/// <param name="msg"></param>
|
||||
private void WritelnSystemInfo(string msg)
|
||||
{
|
||||
msg = DateTimeUtility.GetDateTimeToString(TimeType.TimeOnly) + " >> " + msg;
|
||||
WritelnGameInfo(msg);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 在大厅中,设置按钮的显示和隐藏
|
||||
|
Loading…
x
Reference in New Issue
Block a user