#include #include "sappeer.h" #include "endianhelpers.h" #include "webproxyconn.h" WebProxyConn::WebProxyConn(SAPConnection *conn, QObject *parent) : QObject(parent), _conn(conn), _in(conn->getSocket(501)), _out(conn->getSocket(502)) { connect(_conn, SIGNAL(disconnected()), SLOT(deleteLater())); Q_ASSERT(_in && _out); connect(_in, SIGNAL(messageReceived()), SLOT(handleMessageReceived())); } WebProxyConn::RequestMessage WebProxyConn::unpackRequestMessage(const QByteArray &data) { RequestMessage msg; int offset = 0; msg.command = read(data, offset); msg.subCommand = read(data, offset); msg.type = read(data, offset); msg.transactionId = read(data, offset); const quint32 len = read(data, offset); qDebug() << "command=" << msg.command << "sub=" << msg.subCommand << "type=" << msg.type << "transaction=" << msg.transactionId; qDebug() << QString::fromUtf8(data.mid(offset, len)); return msg; } void WebProxyConn::handleMessageReceived() { QByteArray data = _in->receive(); qDebug() << data.toHex(); RequestMessage req = unpackRequestMessage(data); qDebug() << "End of data"; }