diff options
author | Matt Ranostay <matt.ranostay@konsulko.com> | 2018-05-01 23:15:58 -0700 |
---|---|---|
committer | Matt Ranostay <matt.ranostay@konsulko.com> | 2018-05-13 17:43:33 -0700 |
commit | bb1aee701bc3516c2072a79d3129ee83918df7fd (patch) | |
tree | 150edc50142429ee566edf629a8d3f5dfb3a8557 /message.cpp | |
parent | 6465961f28f40ff5a2da31876f1c23ea3c7f7cec (diff) |
message: add response message support
Add support for callid sequencing, and request data being included
with the response message.
Bug-AGL: SPEC-1404
Change-Id: I259ae3da68e55de17eafe9db534258db5fbc3ef8
Signed-off-by: Matt Ranostay <matt.ranostay@konsulko.com>
Diffstat (limited to 'message.cpp')
-rw-r--r-- | message.cpp | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/message.cpp b/message.cpp index 33211da..3cd4bb9 100644 --- a/message.cpp +++ b/message.cpp @@ -34,15 +34,12 @@ bool Message::createRequest(QString api, QString verb, QJsonValue parameter) return false; } - m_request.append(Call); - m_request.append(9999); - m_request.append(api + (QString)("/") + verb); - m_request.append(QJsonValue(parameter)); + m_request["msgid"] = Call; + m_request["callid"] = 0; + m_request["api"] = api; + m_request["verb"] = verb; + m_request["parameter"] = parameter; - QJsonDocument jdoc; - jdoc.setArray(m_request); - - m_jdoc = jdoc; m_init = true; return true; @@ -50,7 +47,7 @@ bool Message::createRequest(QString api, QString verb, QJsonValue parameter) bool Message::fromJson(QByteArray jsonData) { - QJsonDocument jdoc(QJsonDocument::fromJson(jsonData)); + QJsonDocument jdoc(QJsonDocument::fromJson(jsonData)); if (jdoc.isNull()) { qWarning("Imported invalid JSON: empty appfw message"); @@ -142,5 +139,14 @@ bool Message::fromJDoc(QJsonDocument jdoc) QByteArray Message::toJson(QJsonDocument::JsonFormat format) { - return m_jdoc.toJson(format).data(); + QJsonArray array; + array.append(m_request["msgid"].toInt()); + array.append(m_request["callid"].toInt()); + array.append(m_request["api"].toString() + "/" + m_request["verb"].toString()); + array.append(m_request["parameter"].toJsonValue()); + + QJsonDocument jdoc; + jdoc.setArray(array); + + return jdoc.toJson(format).data(); } |