Skip to content

Commit f2d1c4d

Browse files
committed
[FireNET] Fixed disconnected slot in redisconnector class
1 parent 81b0c09 commit f2d1c4d

4 files changed

Lines changed: 19 additions & 9 deletions

File tree

src/server/UI/mainwindow.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ void MainWindow::on_Input_returnPressed()
212212
qWarning() << "***FULL SERVER STATUS***";
213213

214214
// Main server status
215-
qWarning() << "Server version :" << qApp->applicationVersion().toStdString().c_str();
215+
qWarning() << "Server version :" << gEnv->m_serverFullName.toStdString().c_str();
216216
qWarning() << "Main server (" << gEnv->pSettings->GetVariable("sv_ip").toString().toStdString().c_str() << ":" << gEnv->pSettings->GetVariable("sv_port").toInt() << ") - " << gEnv->m_ServerStatus.m_MainServerStatus.toStdString().c_str();
217217
qWarning() << "Clients count :" << gEnv->pServer->GetClientCount() << "/" << gEnv->pServer->GetMaxClientCount();
218218
qWarning() << "Maximum active clients count :" << gEnv->m_MaxClientCount;

src/server/Workers/Databases/redisconnector.cpp

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,15 @@
1515
RedisConnector::RedisConnector(QObject *parent) : QObject(parent),
1616
pClient(nullptr)
1717
{
18+
connect(&m_Timer, &QTimer::timeout, this, &RedisConnector::update);
1819
}
1920

2021
RedisConnector::~RedisConnector()
2122
{
2223
qDebug() << "~RedisConnector";
2324

25+
m_Timer.stop();
26+
2427
if (IsConnected())
2528
Disconnect();
2629

@@ -64,16 +67,14 @@ bool RedisConnector::Connect()
6467
}
6568

6669
qDebug() << "Redis connected";
70+
m_Timer.start(1000);
6771

6872
return true;
6973
}
7074

7175
bool RedisConnector::IsConnected()
7276
{
73-
if (pClient && pClient->is_connected())
74-
return true;
75-
else
76-
return false;
77+
return pClient && pClient->is_connected() ? true : false;
7778
}
7879

7980
void RedisConnector::Disconnect()
@@ -271,9 +272,15 @@ void RedisConnector::BGSAVE()
271272
qWarning() << "Redis not connected";
272273
}
273274

274-
// TODO - DEPRICATED
275+
void RedisConnector::update()
276+
{
277+
if (!IsConnected())
278+
emit disconnected();
279+
}
280+
275281
void RedisConnector::disconnected()
276282
{
277283
qCritical() << "Redis server disconnected. Database functions not be work!";
278284
gEnv->m_ServerStatus.m_DBStatus = "offline";
285+
m_Timer.stop();
279286
}

src/server/Workers/Databases/redisconnector.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#define REDISCONNECTOR_H
66

77
#include <QObject>
8+
#include <QTimer>
89

910
namespace cpp_redis
1011
{
@@ -30,9 +31,11 @@ class RedisConnector : public QObject
3031
QString GET(const QString &key);
3132
void BGSAVE();
3233
public slots:
33-
void disconnected();
34+
void disconnected();
35+
void update();
3436
private:
3537
cpp_redis::redis_client* pClient;
38+
QTimer m_Timer;
3639
};
3740

3841
#endif // REDISCONNECTOR_H

src/server/main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ int main(int argc, char *argv[])
1414
QApplication* pApp = new QApplication(argc, argv);
1515

1616
// Server buid version, number and type
17-
QString buildVersion = "v.2.1.3";
18-
int buildNumber = 94;
17+
QString buildVersion = "v.2.1.4";
18+
int buildNumber = 2;
1919
QString appVersion = buildVersion + "." + QString::number(buildNumber);
2020
#ifdef QT_NO_DEBUG
2121
QString buildType = ". Release profile";

0 commit comments

Comments
 (0)