Skip to content
Snippets Groups Projects
Commit 53c5b118 authored by alexandr.mruchok's avatar alexandr.mruchok
Browse files

[+] added setRandomServerIfIsEmpty()

parent eb04ab29
No related branches found
No related tags found
No related merge requests found
......@@ -7,6 +7,7 @@
#include <QSettings>
#include <QCoreApplication>
#include <algorithm>
#include <QTime>
#include "DapDataLocal.h"
......@@ -141,6 +142,18 @@ void DapDataLocal::setCurrentServer(int a_serverIndex)
m_currentServer = &m_servers[a_serverIndex];
}
void DapDataLocal::setRandomServerIfIsEmpty()
{
if (!currentServer())
{
qsrand(QTime(0,0,0).secsTo(QTime::currentTime()));
int randIndex = qrand()%(this->servers().count());
this->setCurrentServer(randIndex);
qDebug()<<"Random server chosed:" << this->serverName();
}
}
/// Get login.
/// @return Login.
QString DapDataLocal::login() const
......
......@@ -36,6 +36,7 @@ public:
DapServerInfo* currentServer();
void setCurrentServer(int a_serverIndex);
void setRandomServerIfIsEmpty();
QString locationToIconPath(DapServerLocation loc);
......
......@@ -17,7 +17,6 @@ DapServersListNetworkReply::DapServersListNetworkReply(QNetworkReply *networkRep
if(!jsonDoc.isNull()) {
qDebug() << "Servers list response" << jsonDoc;
if(!jsonDoc.isArray()) {
qCritical() << "Error parse response. Must be array";
emit sigParseResponseError();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment