1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
#include <QtCore/QDebug>
#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<quint8>(data, offset);
msg.subCommand = read<quint8>(data, offset);
msg.type = read<quint8>(data, offset);
msg.transactionId = read<quint8>(data, offset);
const quint32 len = read<quint32>(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";
}
|