mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 23:05:36 +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.
39 lines
886 B
C++
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;
|
|
}
|