summaryrefslogtreecommitdiff
path: root/webproxyconn.cc
diff options
context:
space:
mode:
authorJavier <dev.git@javispedro.com>2015-12-14 22:07:50 +0100
committerJavier <dev.git@javispedro.com>2015-12-14 22:07:50 +0100
commit5abd8e0359cfa1dc2437427f2f0446d8801441cb (patch)
treec02602e849cf47928411b8f0b3e9e6eb34facdc9 /webproxyconn.cc
parent702e018ca9e780bb076033ce5d1d370d4eb7319e (diff)
downloadsapd-5abd8e0359cfa1dc2437427f2f0446d8801441cb.tar.gz
sapd-5abd8e0359cfa1dc2437427f2f0446d8801441cb.zip
initial ack controlflow implementation
Diffstat (limited to 'webproxyconn.cc')
-rw-r--r--webproxyconn.cc35
1 files changed, 28 insertions, 7 deletions
diff --git a/webproxyconn.cc b/webproxyconn.cc
index ae75e1a..1eb4909 100644
--- a/webproxyconn.cc
+++ b/webproxyconn.cc
@@ -19,23 +19,44 @@ WebProxyConn::RequestMessage WebProxyConn::unpackRequestMessage(const QByteArray
int offset = 0;
msg.command = read<quint8>(data, offset);
msg.subCommand = read<quint8>(data, offset);
- msg.type = read<quint8>(data, offset);
+ msg.type = static_cast<RequestMessageType>(read<quint8>(data, offset));
msg.transactionId = read<quint8>(data, offset);
const quint32 len = read<quint32>(data, offset);
+ msg.payload = data.mid(offset, len);
- qDebug() << "command=" << msg.command << "sub=" << msg.subCommand
- << "type=" << msg.type << "transaction=" << msg.transactionId;
+ return msg;
+}
+
+void WebProxyConn::handleStartTransaction(const RequestMessage &msg)
+{
+ QString req = QString::fromUtf8(msg.payload);
+ qDebug() << req;
+}
- qDebug() << QString::fromUtf8(data.mid(offset, len));
+void WebProxyConn::handleCancelTransaction(const RequestMessage &msg)
+{
- return msg;
}
void WebProxyConn::handleMessageReceived()
{
QByteArray data = _in->receive();
- qDebug() << data.toHex();
RequestMessage req = unpackRequestMessage(data);
- qDebug() << "End of data";
+
+ if (req.command != 1 || req.subCommand != 1) {
+ qWarning() << "Invalid command/subcommand: " << req.command << "/" << req.subCommand;
+ return;
+ }
+
+ switch (req.type) {
+ case RequestStartTransaction:
+ handleStartTransaction(req);
+ break;
+ case RequestCancelTransaction:
+ handleCancelTransaction(req);
+ break;
+ default:
+ qWarning() << "Unknown request type" << req.type;
+ }
}