mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-02 06:35:52 +08:00
Initial commit
This commit is contained in:
36
blacklib/samples/com_client/client.cpp
Normal file
36
blacklib/samples/com_client/client.cpp
Normal file
@@ -0,0 +1,36 @@
|
||||
#include <blackmisc/debug.h>
|
||||
#include "client.h"
|
||||
#include <blackmisc/message.h>
|
||||
|
||||
using namespace BlackMisc;
|
||||
|
||||
Client::Client(QObject *parent) : QObject(parent)
|
||||
{
|
||||
connect(&comclient, SIGNAL(doError(QAbstractSocket::SocketError,QString)), this, SLOT(onError(QAbstractSocket::SocketError,QString)));
|
||||
connect(&comclient, SIGNAL(doConnected()), this, SLOT(onClientConnected()));
|
||||
|
||||
QString address = "127.0.0.1";
|
||||
comclient.connectTo(address, 6809);
|
||||
}
|
||||
|
||||
Client::~Client()
|
||||
{
|
||||
}
|
||||
|
||||
void Client::onError(QAbstractSocket::SocketError error, QString message)
|
||||
{
|
||||
bWarning << "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;
|
||||
}
|
||||
Reference in New Issue
Block a user