diff options
author | Davide Beatrici <davidebeatrici@gmail.com> | 2019-05-25 22:33:53 +0300 |
---|---|---|
committer | Davide Beatrici <davidebeatrici@gmail.com> | 2019-05-25 22:33:58 +0300 |
commit | da7baf5313c35b87f39ee8394eac6cecaa328772 (patch) | |
tree | 605e400d28cc3d852eb5e0384e8417a55da8bf7f /src/murmur/ServerUser.h | |
parent | 4e8391397409122c860797042a39d95257407ed9 (diff) |
ServerUser: use QTime instead of std::chrono and ctime
The legacy implementation (with ctime), used when std::chrono is not available (C++ < 11), caused the client's messages to be permanently blocked until it reconnected.
More specifically, millisecondsBetween() always returned 0.
This commit replaces both implementations with a simpler one which makes use of QTime.
Diffstat (limited to 'src/murmur/ServerUser.h')
-rw-r--r-- | src/murmur/ServerUser.h | 16 |
1 files changed, 2 insertions, 14 deletions
diff --git a/src/murmur/ServerUser.h b/src/murmur/ServerUser.h index 36ba8d8da..09dee4dcb 100644 --- a/src/murmur/ServerUser.h +++ b/src/murmur/ServerUser.h @@ -7,6 +7,7 @@ #define MUMBLE_MURMUR_SERVERUSER_H_ #include <QtCore/QStringList> +#include <QtCore/QTime> #ifdef Q_OS_UNIX #include <sys/socket.h> @@ -14,13 +15,6 @@ #include <winsock2.h> #endif -// <chrono> was introduced in C++11 -#if __cplusplus > 199711LL -#include <chrono> -#else -#include <ctime> -#endif - #include "Connection.h" #include "Timer.h" #include "User.h" @@ -62,18 +56,12 @@ struct WhisperTarget { class Server; -#if __cplusplus > 199711L - typedef std::chrono::time_point<std::chrono::steady_clock> time_point; -#else - typedef clock_t time_point; -#endif - // Simple algorithm for rate limiting class LeakyBucket { private: unsigned int tokensPerSec, maxTokens; long currentTokens; - time_point lastUpdate; + QTime lastUpdate; public: // Returns true if packets should be dropped |