summary refs log tree commit diff
path: root/include
diff options
context:
space:
mode:
authorKonstantinos Sideris <sideris.konstantin@gmail.com>2017-11-06 22:14:16 +0200
committerKonstantinos Sideris <sideris.konstantin@gmail.com>2017-11-06 22:14:16 +0200
commit24dd76ee0bca1a593781d366a41017f5b1d9ec07 (patch)
treea8ef42603c3834e8c0489dc01180a0902296e4a2 /include
parentAdjust appveyor configuration (diff)
downloadnheko-24dd76ee0bca1a593781d366a41017f5b1d9ec07.tar.xz
Parse unsigned key
Diffstat (limited to 'include')
-rw-r--r--include/events/Event.h26
1 files changed, 26 insertions, 0 deletions
diff --git a/include/events/Event.h b/include/events/Event.h

index 84c21907..f6620a2c 100644 --- a/include/events/Event.h +++ b/include/events/Event.h
@@ -60,6 +60,24 @@ isMessageEvent(EventType type); bool isStateEvent(EventType type); +class UnsignedData + : public Deserializable + , public Serializable +{ +public: + double age() const { return age_; } + QString transactionId() const { return transaction_id_; } + + bool isEmpty() const { return age_ <= 0 && transaction_id_.isEmpty(); } + + void deserialize(const QJsonValue &data) override; + QJsonObject serialize() const override; + +private: + double age_ = 0; + QString transaction_id_; +}; + template<class Content> class Event : public Deserializable @@ -68,6 +86,7 @@ class Event public: Content content() const; EventType eventType() const; + UnsignedData unsignedData() const { return unsignedData_; } void deserialize(const QJsonValue &data) override; QJsonObject serialize() const override; @@ -75,6 +94,7 @@ public: private: Content content_; EventType type_; + UnsignedData unsignedData_; }; template<class Content> @@ -102,6 +122,9 @@ Event<Content>::deserialize(const QJsonValue &data) content_.deserialize(object.value("content")); type_ = extractEventType(object); + + if (object.contains("unsigned")) + unsignedData_.deserialize(object.value("unsigned")); } template<class Content> @@ -151,6 +174,9 @@ Event<Content>::serialize() const object["content"] = content_.serialize(); + if (!unsignedData_.isEmpty()) + object["unsigned"] = unsignedData_.serialize(); + return object; } } // namespace events