Skip to content

Commit

Permalink
fix: 修复了保活和检测被踢逻辑
Browse files Browse the repository at this point in the history
  • Loading branch information
SALTWOOD committed May 26, 2024
1 parent a1f8489 commit 44ddf03
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions CSharp-OpenBMCLAPI/Modules/Cluster.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using CSharpOpenBMCLAPI.Modules.WebServer;
using Konsole;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
using SocketIOClient;
using System.ComponentModel;
using System.Diagnostics;
Expand Down Expand Up @@ -392,12 +391,12 @@ private void _keepAliveMessageParser(SocketIOResponse resp)
{
try
{
var returns = resp.GetValue<List<object?>>(0);
string? message = returns.First() as string;
bool? enabled = returns.Last() as bool?;
if (message == null)
var returns = resp.GetValue<List<JsonElement>>(0);
string? message = returns.First().GetString();
bool enabled = !(returns.Last().ValueKind == JsonValueKind.False);
if (enabled)
{
string? time = returns.Last() as string;
string? time = returns.Last().GetString();
Logger.Instance.LogSystem($"保活成功 at {time},served {Utils.GetLength(this.counter.bytes)}({this.counter.bytes} bytes)/{this.counter.hits} hits");
}
else
Expand All @@ -406,8 +405,11 @@ private void _keepAliveMessageParser(SocketIOResponse resp)
if (this.WantEnable)
{
Logger.Instance.LogError($"保活失败:{returns},将在 10 分钟后重新上线");
Thread.Sleep(10 * 60 * 1000);
this.Enable().Wait();
Task.Run(() =>
{
Thread.Sleep(10 * 60 * 1000);
this.Enable().Wait();
});
}
}
}
Expand Down

0 comments on commit 44ddf03

Please sign in to comment.