diff options
| author | Dark1-dev <shansarkar272@gmail.com> | 2023-03-01 21:30:57 +0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-03-01 21:30:57 +0600 |
| commit | 60a301a93b6057bb2c54ac04a7c38c38389037b3 (patch) | |
| tree | b09c5f8bc0045828c660654d8ed6744663856202 /src/TcpTasks/Updater/scheduleupdater.cpp | |
| parent | c784240d1af68dbd8d0466822b34fd05d6ccdda1 (diff) | |
| download | Masterserver-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.cpp | 29 |
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; +} |
