Browse Source

Pinger uses active clients list directly.

Mihawk 10 years ago
parent
commit
f09326232b
5 changed files with 24 additions and 7 deletions
  1. 10 0
      ActiveClient.cpp
  2. 3 0
      ActiveClient.h
  3. 5 0
      App.cpp
  4. 2 0
      App.h
  5. 4 7
      SshClient.cpp

+ 10 - 0
ActiveClient.cpp

@@ -83,6 +83,16 @@ bool ActiveClient::hasHostName() const {
   return myHasHostNameFlag;
 }
 
+// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+const QHostAddress& ActiveClient::address() const {
+  return myQuery->address();
+}
+
+// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+quint16 ActiveClient::port() const {
+  return myQuery->port();
+}
+
 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 void ActiveClient::queryError(ServerQuery::Error)
 {

+ 3 - 0
ActiveClient.h

@@ -78,6 +78,9 @@ public:
   */
   void              setAddress(const QString& hostName, const QHostAddress &hostAddress, quint16 port);
 
+  const QHostAddress& address() const;
+  quint16 port() const;
+
   /**
     Returns the address of the server we are monitoring.
 

+ 5 - 0
App.cpp

@@ -380,6 +380,11 @@ void App::setReplyHashAndWaitForReply(const QString &serverAddress, const QStrin
   }
 }
 
+// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+const QList<ActiveClient*> App::clients() const {
+  return myClients;
+}
+
 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 void App::incrementReplyCounters(const QString &hash, int userCount, int channelCount, int playerCount, int serverCount)
 {

+ 2 - 0
App.h

@@ -55,6 +55,8 @@ public:
   */
   ~App();
 
+  const QList<ActiveClient*> clients() const;
+
   /**
     Prints directly to console and to anyone connected via telnet.
 

+ 4 - 7
SshClient.cpp

@@ -20,6 +20,8 @@ along with this program.  If not, see < http://www.gnu.org/licenses/ >.
 #include "SshClient.h"
 #include "App.h"
 #include "Settings.h"
+#include "ActiveClient.h"
+
 #include <QProcess>
 #include <QRegExp>
 #include <QDateTime>
@@ -266,13 +268,8 @@ void SshClient::parse(const QDateTime &time, const QString &command, const QStri
   if(command == "REQ_ASSIGNMENTS")
   {
     myApp->print("Server list requested... Sending it now!\n");
-    // TODO: Maybe fetching server data directly from ActiveClients list is a better idea
-    Settings::ServerList serverList = Settings::globalInstance()->serverList();
-    Settings::Server server;
-    foreach(server, serverList)
-    {
-      // Let the reply be send after the pinging is done
-      Pinger* pinger = new Pinger(QHostAddress(server.address), server.port, this);
+    foreach (ActiveClient* ac, myApp->clients()) {
+      Pinger* pinger = new Pinger(ac->address(), ac->port(), this);
       connect(pinger, SIGNAL(finished(QHostAddress,quint16,int)), SLOT(assignmentsReply(QHostAddress,quint16,int)));
       pinger->ping();
     }