mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-23 07:15:35 +08:00
- Changed: Qt5 has a different method to connect signals and slots together based on C++x11 Migrated the first bunch of occurences to the new method. - Fixed: CDebug singleton was not created yet in BlackD. Crashed the application.
41 lines
1.1 KiB
C++
41 lines
1.1 KiB
C++
#include "blackmisc/debug.h"
|
|
#include "server.h"
|
|
|
|
using namespace BlackMisc;
|
|
|
|
Server::Server(QObject *parent) : QObject(parent), server(IContext::getInstance())
|
|
{
|
|
QHostAddress local = QHostAddress(QHostAddress::LocalHost);
|
|
|
|
server.Host(local, 6809);
|
|
|
|
connect(&server, static_cast<void (BlackMisc::CComServer::*)(QString &, QByteArray &)>(&BlackMisc::CComServer::doMessageReceived),
|
|
this, &Server::onData);
|
|
|
|
CMessageSystem myMessageSystem;
|
|
|
|
bAppInfo << "Com Server running. \n";
|
|
}
|
|
|
|
Server::~Server()
|
|
{
|
|
}
|
|
|
|
void Server::onData(QString &messageID, QByteArray &message)
|
|
{
|
|
BlackMisc::IMessage* test = BlackMisc::CMessageFactory::getInstance().create(messageID);
|
|
QDataStream stream(&message, QIODevice::ReadOnly);
|
|
|
|
Q_ASSERT(test);
|
|
*test << stream;
|
|
|
|
CMessageDispatcher::getInstance().append(test);
|
|
CMessageDispatcher::getInstance().dispatch();
|
|
|
|
}
|
|
|
|
void TestMessageHandler::onTestMessage(const TestMessage *testmessage)
|
|
{
|
|
bAppDebug << "Message ID: " << testmessage->getID() << " with text: " << testmessage->getTestString();
|
|
}
|