diff options
Diffstat (limited to 'webproxyconn.cc')
-rw-r--r-- | webproxyconn.cc | 35 |
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; + } } |