Skip to content

Commit

Permalink
Fix task scheduling
Browse files Browse the repository at this point in the history
  • Loading branch information
MrMicky-FR committed Dec 25, 2023
1 parent db19732 commit 8095a56
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions AzLink/AzLink.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ namespace Oxide.Plugins;
[Description("Link your Azuriom website with an Oxide server.")]
class AzLink : CovalencePlugin
{
private const string AzLinkVersion = "0.1.0";
private const string AzLinkVersion = "0.1.1";

private DateTime lastSent = DateTime.MinValue;
private DateTime lastFullSent = DateTime.MinValue;
private DateTime lastSent = DateTime.Now;
private DateTime lastFullSent = DateTime.Now;

private void Init()
{
Expand Down Expand Up @@ -92,22 +92,22 @@ private void TryFetch()
return;
}

if ((now - lastSent).Seconds < 15)
if ((now - lastSent).TotalSeconds < 15)
{
return;
}

lastSent = now;

var sendFull = now.Minute % 15 == 0 && (now - lastFullSent).Seconds > 60;
var full = now.Minute % 15 == 0 && (now - lastFullSent).TotalSeconds >= 60;

if (sendFull)
if (full)
{
lastFullSent = now;
}

RunFetch(res => DispatchCommands(res.Commands),
code => LogError("Unable to send data to the website (code {0})", code), sendFull);
code => LogError("Unable to send data to the website (code {0})", code), full);
}

private void RunFetch(Action<FetchResponse> callback, Action<int> errorHandler, bool sendFullData)
Expand Down

0 comments on commit 8095a56

Please sign in to comment.