summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--callmessage.cpp5
-rw-r--r--message.h5
-rw-r--r--responsemessage.cpp27
-rw-r--r--responsemessage.h7
4 files changed, 13 insertions, 31 deletions
diff --git a/callmessage.cpp b/callmessage.cpp
index 4afb071..1dfa72e 100644
--- a/callmessage.cpp
+++ b/callmessage.cpp
@@ -49,8 +49,7 @@ QByteArray CallMessage::serialize(QJsonDocument::JsonFormat format)
array.append(m_request["api"].toString() + "/" + m_request["verb"].toString());
array.append(m_request["parameter"].toJsonValue());
- QJsonDocument jdoc;
- jdoc.setArray(array);
+ m_jdoc.setArray(array);
- return jdoc.toJson(format).data();
+ return m_jdoc.toJson(format).data();
}
diff --git a/message.h b/message.h
index 0b5ad64..38936f3 100644
--- a/message.h
+++ b/message.h
@@ -37,7 +37,10 @@ class Message
{
public:
Message();
- void setAdditionalData(QByteArray data) {};
+ virtual bool setAdditionalData(QByteArray data)
+ {
+ return false;
+ }
QByteArray send(QWebSocket& transport, unsigned int callid);
inline bool isComplete() const
diff --git a/responsemessage.cpp b/responsemessage.cpp
index 96dab97..9f8e6f2 100644
--- a/responsemessage.cpp
+++ b/responsemessage.cpp
@@ -22,35 +22,10 @@
#include "responsemessage.h"
-//deprecated method call new constructor and setAdditionalData() instead:
-ResponseMessage::ResponseMessage(QByteArray request)
-{
-
- QJsonDocument jdoc(QJsonDocument::fromJson(request));
-
- if (!jdoc.isArray()) {
- qWarning("Invalid appfw message: not an array");
- return;
- }
-
- QJsonArray msg = jdoc.array();
-
- if (msg.size() != 4) {
- qWarning("Invalid appfw message: invalid array size");
- return;
- }
-
- QStringList api_str_list = msg[2].toString().split(QRegExp("/"));
-
- m_request["msgid"] = msg.at(0);
- m_request["callid"] = msg.at(1);
- m_request["api"] = api_str_list[0];
- m_request["verb"] = api_str_list[1];
- m_request["parameter"] = msg.at(3);
-}
ResponseMessage::ResponseMessage(QJsonDocument content)
{
+ m_jdoc = content;
QJsonArray msg = content.array();
if (!msg[2].isObject()) {
qWarning("Invalid appfw payload: no JSON object");
diff --git a/responsemessage.h b/responsemessage.h
index edad3b1..bac4296 100644
--- a/responsemessage.h
+++ b/responsemessage.h
@@ -60,6 +60,11 @@ class ResponseMessage : public Message
return m_reply_data;
}
+ bool getCallId(unsigned int *id) const override
+ {
+ *id = m_reply_callid;
+ return true;
+ }
bool isEvent() override
{
return false;
@@ -70,7 +75,7 @@ class ResponseMessage : public Message
return true;
}
- bool setAdditionalData(QByteArray data);
+ bool setAdditionalData(QByteArray data) override;
bool copyCallId(unsigned int *id);
QByteArray serialize(QJsonDocument::JsonFormat format = QJsonDocument::Compact) override;