Client.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #ifndef CLIENT_H
  2. #define CLIENT_H
  3. #include "QWClient.h"
  4. #include <QString>
  5. #include <QStringList>
  6. #include <QList>
  7. #include <QTime>
  8. #include "ServerQuery.h"
  9. class App;
  10. class QTime;
  11. class QTimer;
  12. class ActiveClient;
  13. class Client : public QWClient
  14. {
  15. public:
  16. Client(App* app, ActiveClient* ac);
  17. ~Client();
  18. void run();
  19. void disconnect();
  20. void say(const QString& msg);
  21. void sayTeam(const QString& msg);
  22. void setTeam(const QString& msg);
  23. void setSocket(class QTcpSocket* socket);
  24. void retryConnection(); //unused
  25. bool isOnServer() const;
  26. bool isMuted() const;
  27. void setPlayerList(PlayerList &playerList);
  28. protected:
  29. void onLevelChanged(int playerNum, const char *levelName, float gravity, float stopSpeed, float maxSpeed, float spectatorMaxSpeed, float accelerate, float airAccelerate, float waterAccelerate, float friction, float waterFriction, float entGravity);
  30. void onDisconnect();
  31. void onPrint(int level, const char *msg);
  32. void onChallenge();
  33. void onConnection();
  34. void onConnected();
  35. void onDownloadStarted(const char *fileName);
  36. void onDownloadFinished();
  37. void onDownloadProgress(int percent);
  38. void onStuffedCmd(const char *cmd);
  39. void onError(const char *description);
  40. void onOOBPrint(const char *msg);
  41. private:
  42. ActiveClient* myActiveClient;
  43. App* myApp;
  44. QTime myEndFloodTime;
  45. bool myFloodMsgPrinted;
  46. int myConnectionRetries;
  47. static const int ConnectionRetries = 10;
  48. QString myPrintLine;
  49. bool myDownloadProgressPrintedFlag;
  50. bool myOnServerFlag;
  51. bool myMutedFlag;
  52. QTimer* myJoinMessageTimer;
  53. QTime myQWBroadcastFloodTime;
  54. QTime mySpamBroadcastFloodTime;
  55. bool myJoinMessagePrinted;
  56. PlayerList myPlayerList;
  57. void print(const QString& msg);
  58. void parsePrintedLine();
  59. static QString parseNameFun(const QString& string);
  60. };
  61. #endif // CLIENT_H