Skip to content

Commit

Permalink
这onebot没写对吧
Browse files Browse the repository at this point in the history
  • Loading branch information
Cyl18 committed Jun 29, 2022
1 parent 36fd4f0 commit 225a64f
Showing 1 changed file with 13 additions and 17 deletions.
30 changes: 13 additions & 17 deletions WFBot/Orichalt/OrichaltConnectors/OneBotConnector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,18 @@ public async Task Init()
await Task.Delay(1000);
if (!wsevent.IsAvailable)
{
Console.WriteLine("OneBot连接失败, 将在5秒后重试···");
InitializationTimer = new Timer(TimeSpan.FromSeconds(5).TotalMilliseconds);
InitializationTimer.Elapsed += TryInitOneBot;
InitializationTimer.Start();
while (true)
{
Console.WriteLine("OneBot连接失败, 将在5秒后重试···");
await Task.Delay(5000);
wsevent.StartListen();
if (!wsevent.IsAvailable)
{
continue;
}
Console.WriteLine("OneBot已连接.");
break;
}
}
else
{
Expand All @@ -126,19 +134,7 @@ public async Task Init()
}
Console.WriteLine("OneBot已连接.");*/
}

private void TryInitOneBot(object sender, ElapsedEventArgs e)
{
wsevent.StartListen();
if (!wsevent.IsAvailable)
{
Console.WriteLine("OneBot连接失败, 将在5秒后重试···");
return;
}
Console.WriteLine("OneBot已连接.");
InitializationTimer.Stop();
}


protected virtual void OnOneBotMessage(OneBotContext e)
{
OneBotMessageReceived?.Invoke(this, e);
Expand Down

0 comments on commit 225a64f

Please sign in to comment.