aboutsummaryrefslogtreecommitdiff
path: root/src/UdpTasks/StatusChecker/getnextserver.cpp
blob: 5b9bb20929db7589f20eec3c566a2b21b6c4281b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include "statuschecker.h"

QSqlQuery StatusChecker::getNextServer(const int &currentServerId)
{
    // select server with >id
    QSqlQuery q;
    QString selectString = "SELECT id, ip, queryport, gamename, f_auth FROM serverlist "
                           "WHERE id > :currentServerID "
                           "AND (dt_updated > :timestamp OR dt_sync > :timestamp)"
                           "LIMIT 1";

    // bind values and execute
    q.prepare(selectString);
    q.bindValue(":currentServerID", currentServerId);
    q.bindValue(":timestamp", QDateTime::currentDateTime()
                .addSecs(-_coreObject->Settings.ListenServerSettings.serverttl_s)
                .toSecsSinceEpoch());
    if ( ! q.exec() )
        reportQuery(q);

    return q;
}