ActiveClient.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /*
  2. GNU General Public License version 3 notice
  3. Copyright (C) 2012 Mihawk <luiz@netdome.biz>. All rights reserved.
  4. This program is free software: you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation, either version 3 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program. If not, see < http://www.gnu.org/licenses/ >.
  14. */
  15. #ifndef ACTIVECLIENT_H
  16. #define ACTIVECLIENT_H
  17. #include <QObject>
  18. #include <QString>
  19. #include "ServerQuery.h"
  20. class QHostAddress;
  21. class QTimer;
  22. class QTime;
  23. class Client;
  24. class App;
  25. class ActiveClient: public QObject
  26. {
  27. Q_OBJECT
  28. public:
  29. ActiveClient(App* app, QObject *parent = 0);
  30. virtual ~ActiveClient();
  31. Client* client();
  32. void run();
  33. void setAddress(const QHostAddress &address, quint16 port);
  34. const QString serverAddressString();
  35. quint8 playerCount() const;
  36. void setReplyHash(const QString& hash); //this activates the 5 seconds reply timer too
  37. const QString& replyHash() const;
  38. void incrementReplyCounters(int userCount, int channelCount, int playerCount, int serverCount);
  39. bool isWaitingReply() const;
  40. private slots:
  41. void queryFinished();
  42. void queryError(ServerQuery::Error err);
  43. private:
  44. App* myApp;
  45. Client* myClient;
  46. ServerQuery* myQuery;
  47. QTime* myDisconnectTime;
  48. /* Count server reply while timer is active */
  49. QString myReplyHash;
  50. QTimer* myBroadcastReplyTimer;
  51. QTimer* myQueryTimer;
  52. quint32 myQueryInterval;
  53. int myUniqueUserCount;
  54. int myUniqueChannelCount;
  55. int myUniqueServerCount;
  56. int myUniquePlayerCount;
  57. bool myReplyTimerWasActive;
  58. };
  59. #endif // ACTIVECLIENT_H