mirror of
https://github.com/project-redbud/FunGame-Core.git
synced 2025-12-05 16:16:33 +00:00
心跳和 log 优化
This commit is contained in:
parent
5445ea141b
commit
984a7fd5a1
@ -1,5 +1,6 @@
|
|||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using Milimoe.FunGame.Core.Library.Constant;
|
using Milimoe.FunGame.Core.Library.Constant;
|
||||||
|
using Milimoe.FunGame.Core.Library.Exception;
|
||||||
|
|
||||||
namespace Milimoe.FunGame.Core.Api.Utility
|
namespace Milimoe.FunGame.Core.Api.Utility
|
||||||
{
|
{
|
||||||
@ -180,7 +181,7 @@ namespace Milimoe.FunGame.Core.Api.Utility
|
|||||||
if (!Directory.Exists(path)) Directory.CreateDirectory(path);
|
if (!Directory.Exists(path)) Directory.CreateDirectory(path);
|
||||||
path = Path.Combine(path, filename);
|
path = Path.Combine(path, filename);
|
||||||
}
|
}
|
||||||
else path = $@"{AppDomain.CurrentDomain.BaseDirectory}{filename}";
|
else path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, filename);
|
||||||
// 写入内容
|
// 写入内容
|
||||||
StreamWriter writer = File.Exists(path) ? new(path, !overwrite, General.DefaultEncoding) : new(path, false, General.DefaultEncoding);
|
StreamWriter writer = File.Exists(path) ? new(path, !overwrite, General.DefaultEncoding) : new(path, false, General.DefaultEncoding);
|
||||||
writer.WriteLine(content);
|
writer.WriteLine(content);
|
||||||
@ -200,5 +201,11 @@ namespace Milimoe.FunGame.Core.Api.Utility
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="msg"></param>
|
/// <param name="msg"></param>
|
||||||
public static void AppendErrorLog(string msg) => WriteTXT(DateTimeUtility.GetDateTimeToString(TimeType.General) + ": " + msg + "\r\n", DateTimeUtility.GetDateTimeToString("yyyy-MM-dd") + ".log", "logs");
|
public static void AppendErrorLog(string msg) => WriteTXT(DateTimeUtility.GetDateTimeToString(TimeType.General) + ": " + msg + "\r\n", DateTimeUtility.GetDateTimeToString("yyyy-MM-dd") + ".log", "logs");
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 追加错误日志 默认写入logs文件夹下的当日日期.log文件
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
public static void AppendErrorLog(Exception e) => AppendErrorLog(e.GetErrorInfo());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -77,10 +77,11 @@ namespace Milimoe.FunGame.Core.Library.Common.Architecture
|
|||||||
{
|
{
|
||||||
if (!SendingHeartBeat) _SendingHeartBeat = true;
|
if (!SendingHeartBeat) _SendingHeartBeat = true;
|
||||||
// 发送心跳包
|
// 发送心跳包
|
||||||
|
_LastHeartbeatReceived = false;
|
||||||
if (await _HTTPClient.Send(SocketMessageType.HeartBeat) == SocketResult.Success)
|
if (await _HTTPClient.Send(SocketMessageType.HeartBeat) == SocketResult.Success)
|
||||||
{
|
{
|
||||||
await Task.Delay(4 * 1000);
|
await Task.Delay(4 * 1000);
|
||||||
AddHeartBeatFaileds();
|
if (!_LastHeartbeatReceived) AddHeartBeatFaileds();
|
||||||
}
|
}
|
||||||
else AddHeartBeatFaileds();
|
else AddHeartBeatFaileds();
|
||||||
await Task.Delay(20 * 1000);
|
await Task.Delay(20 * 1000);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user