aboutsummaryrefslogtreecommitdiff
path: root/src/TcpTasks/Updater/scheduleupdater.cpp
diff options
context:
space:
mode:
authorDark1-dev <shansarkar272@gmail.com>2023-03-01 21:30:57 +0600
committerGitHub <noreply@github.com>2023-03-01 21:30:57 +0600
commit60a301a93b6057bb2c54ac04a7c38c38389037b3 (patch)
treeb09c5f8bc0045828c660654d8ed6744663856202 /src/TcpTasks/Updater/scheduleupdater.cpp
parentc784240d1af68dbd8d0466822b34fd05d6ccdda1 (diff)
downloadMasterserver-Qt5-60a301a93b6057bb2c54ac04a7c38c38389037b3.tar.gz
Masterserver-Qt5-60a301a93b6057bb2c54ac04a7c38c38389037b3.zip
Add files via upload
Diffstat (limited to 'src/TcpTasks/Updater/scheduleupdater.cpp')
-rw-r--r--src/TcpTasks/Updater/scheduleupdater.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/TcpTasks/Updater/scheduleupdater.cpp b/src/TcpTasks/Updater/scheduleupdater.cpp
new file mode 100644
index 0000000..7a96d6e
--- /dev/null
+++ b/src/TcpTasks/Updater/scheduleupdater.cpp
@@ -0,0 +1,29 @@
+#include "syncupdater.h"
+
+bool SyncUpdater::scheduleUpdater()
+{
+ // schedule sync X seconds apart (prevent network spikes)
+ connect(&_syncTicker, &QTimer::timeout, this, &SyncUpdater::onSyncTickerAction);
+ _syncTicker.setInterval( _graceTime_ms );
+
+ // set update timer
+ connect(&_updaterTimer, &QTimer::timeout, [this]
+ {
+ // reset and start ticker
+ _syncIndex = 0;
+ _syncTicker.start();
+ });
+
+ _updaterTimer.setInterval( _coreObject->Settings.SyncerSettings.syncInterval_s * 1000);
+ _updaterTimer.start();
+
+ // complete startup
+ _coreObject->Log.logEvent("info", QStringLiteral("sync with other masterservers every %1 seconds")
+ .arg(_coreObject->Settings.SyncerSettings.syncInterval_s));
+
+ // run immediately at startup
+ _syncIndex = 0;
+ _syncTicker.start();
+
+ return true;
+}