aboutsummaryrefslogtreecommitdiff
path: root/connectiondata.cpp
diff options
context:
space:
mode:
authorKitsune Ral <Kitsune-Ral@users.sf.net>2017-07-15 13:07:53 +0900
committerGitHub <noreply@github.com>2017-07-15 13:07:53 +0900
commit3dfb74af71fe0cceaeb14d1ef0ade846f3a659f9 (patch)
tree40482bd167f1e086541ad71cdf634324b40383c6 /connectiondata.cpp
parent47c2015beb75693c7181fb7359a4aa166e926fe7 (diff)
parent749def2b983d2338272c0891d15de20df22e2eea (diff)
downloadlibquotient-3dfb74af71fe0cceaeb14d1ef0ade846f3a659f9.tar.gz
libquotient-3dfb74af71fe0cceaeb14d1ef0ade846f3a659f9.zip
Merge pull request #72 from QMatrixClient/kitsune-send-events
Events creation and sending
Diffstat (limited to 'connectiondata.cpp')
-rw-r--r--connectiondata.cpp10
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);
+}