Commit d54ecb5f authored by Renaud Guezennec's avatar Renaud Guezennec

add stuff to test network automatically

parent d5bb0337
Subproject commit 2c0641298b3f5041be55155ae29f44380b834446
Subproject commit cbe0c4266f2cc34b77157616248aa239f6c47e53
Subproject commit 63b89cf46901c3d02b4d0f8bca6353d4c7037f0f
Subproject commit ab7a699db00aa2814695262319ef133777a7527f
#include "messagedispatcher.h"
#include "network/networkmessagereader.h"
#include <QDateTime>
#include <QStringView>
MessageDispatcher::MessageDispatcher(QObject *parent) : QObject(parent)
{
QDateTime time = QDateTime::currentDateTime();
QString path = QStringLiteral("/home/renaud/www/DataServer_%1.log").arg(time.toString(Qt::ISODate));
m_file.setFileName(path);
if(m_file.open(QIODevice::WriteOnly))
{
m_recorder.setDevice(&m_file);
}
}
void MessageDispatcher::dispatchMessage(QByteArray data, Channel* channel, TcpClient* emitter)
......@@ -14,6 +24,26 @@ void MessageDispatcher::dispatchMessage(QByteArray data, Channel* channel, TcpCl
msg->setData(data);
if(m_recording)
{
static QHash<TcpClient*,int> tableEmitter;
static int counter = 0;
int i = 0;
if(tableEmitter.contains(emitter))
{
i = tableEmitter[emitter];
}
else
{
tableEmitter[emitter] = counter;
i = counter;
++counter;
}
m_recorder << QTime::currentTime().toString(QStringLiteral("hh:mm:ss:zzz")) << "_" << i << "_" << data.toBase64() << "\n";
m_recorder.flush();
}
qDebug() << "[Server][Received Message]" <<cat2String(msg->header()) << act2String(msg->header()) << channel << emitter->getName() << msg->getSize();
if(msg->category()== NetMsg::AdministrationCategory)
......
......@@ -29,6 +29,10 @@ signals:
public slots:
void dispatchMessage(QByteArray msg, Channel* channel, TcpClient* emitter);
private:
bool m_recording = true;
QTextStream m_recorder;
QFile m_file;
};
#endif // MESSAGEDISPATCHER_H
......@@ -14,6 +14,8 @@ DEFINES += VERSION_MAJOR=1 VERSION_MIDDLE=9 VERSION_MINOR=0
TEMPLATE = subdirs
SUBDIRS = client server
CONFIG += TESTS
TESTS {
message("test")
SUBDIRS += tests
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment