Files
pilotclient/samples/com_client/client.cpp
Roland Winklmeier 6127ac4ef5 Refs #41:
- 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.
2013-07-06 00:25:46 +02:00

39 lines
886 B
C++

#include <blackmisc/debug.h>
#include "client.h"
#include <blackmisc/message.h>
using namespace BlackMisc;
Client::Client(QObject *parent) : QObject(parent), comclient(IContext::getInstance())
{
connect(&comclient, &BlackMisc::CComClient::doError,
this, &Client::onError);
connect(&comclient, &BlackMisc::CComClient::doConnected,
this, &Client::onClientConnected);
QString address = "127.0.0.1";
comclient.connectTo(address, 6809);
}
Client::~Client()
{
}
void Client::onError(QAbstractSocket::SocketError error, QString message)
{
bAppWarning << "Socket error!";
}
void Client::onClientConnected()
{
QByteArray message_data;
QDataStream out(&message_data, QIODevice::WriteOnly);
IMessage* testmsg = new TestMessage();
*testmsg >> out;
comclient.sendMessage(testmsg->getID(), message_data);
delete testmsg;
}