diff options
Diffstat (limited to 'connectiondata.cpp')
-rw-r--r-- | connectiondata.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/connectiondata.cpp b/connectiondata.cpp index 6c7eff8c..cd91ef27 100644 --- a/connectiondata.cpp +++ b/connectiondata.cpp @@ -21,6 +21,7 @@ #include "logging.h" #include <QtNetwork/QNetworkAccessManager> +#include <cstdlib> using namespace QMatrixClient; @@ -35,6 +36,9 @@ struct ConnectionData::Private QUrl baseUrl; QString accessToken; QString lastEvent; + + mutable unsigned int txnCounter = 0; + const int id = std::rand(); // We don't really care about pure randomness }; ConnectionData::ConnectionData(QUrl baseUrl) @@ -89,3 +93,9 @@ void ConnectionData::setLastEvent(QString identifier) { d->lastEvent = identifier; } + +QByteArray ConnectionData::generateTxnId() const +{ + return QByteArray::number(d->id) + 'q' + + QByteArray::number(++d->txnCounter); +} |