Client.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #ifndef CLIENT_H
  2. #define CLIENT_H
  3. #include "QWClient.h"
  4. #include <QString>
  5. #include <QList>
  6. class App;
  7. class QTcpSocket;
  8. class QTime;
  9. class Client : public QWClient
  10. {
  11. public:
  12. Client(App* app);
  13. ~Client();
  14. void disconnect();
  15. void say(const QString& msg);
  16. void sayTeam(const QString& msg);
  17. void setTeam(const QString& msg);
  18. void setSocket(class QTcpSocket* socket);
  19. void retryConnection(); //unused
  20. bool isOnServer() const;
  21. protected:
  22. 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);
  23. void onDisconnect();
  24. void onPrint(int level, const char *msg);
  25. void onChallenge();
  26. void onConnection();
  27. void onConnected();
  28. void onDownloadStarted(const char *fileName);
  29. void onDownloadFinished();
  30. void onDownloadProgress(int percent);
  31. void onStuffedCmd(const char *cmd);
  32. void onError(const char *description);
  33. void onOOBPrint(const char *msg);
  34. private:
  35. App* myApp;
  36. QTcpSocket* mySocket;
  37. QTime* myEndFloodTimer;
  38. bool myFloodMsgPrinted;
  39. int myConnectionRetries;
  40. static const int ConnectionRetries = 10;
  41. QString myPrintLine;
  42. bool myDownloadProgressPrintedFlag;
  43. bool myOnServerFlag;
  44. void print(const QString& msg);
  45. void parsePrintedLine();
  46. static QString parseNameFun(const QString& string);
  47. };
  48. #endif // CLIENT_H