From 5abd8e0359cfa1dc2437427f2f0446d8801441cb Mon Sep 17 00:00:00 2001 From: Javier Date: Mon, 14 Dec 2015 22:07:50 +0100 Subject: initial ack controlflow implementation --- webproxyconn.cc | 35 ++++++++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 7 deletions(-) (limited to 'webproxyconn.cc') 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(data, offset); msg.subCommand = read(data, offset); - msg.type = read(data, offset); + msg.type = static_cast(read(data, offset)); msg.transactionId = read(data, offset); const quint32 len = read(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; + } } -- cgit v1.2.3