Initial commit

This commit is contained in:
Roland Winklmeier
2013-02-15 18:50:17 +01:00
parent 57214c1c1e
commit 584251e0a8
125 changed files with 10640 additions and 0 deletions

View File

@@ -0,0 +1,9 @@
FILE(GLOB sample_com_server_SOURCES *.cpp)
SET(sample_com_server_HEADERS server.h)
QT4_WRAP_CPP(sample_com_server_HEADERS_MOC ${sample_com_server_HEADERS})
ADD_EXECUTABLE(sample_com_server ${sample_com_server_SOURCES} ${sample_com_server_HEADERS_MOC})
TARGET_LINK_LIBRARIES(sample_com_server blackmisc ${QT_LIBRARIES})
SET_TARGET_PROPERTIES(sample_com_server PROPERTIES PROJECT_LABEL "Samples - Com Server")

View File

@@ -0,0 +1,16 @@
#include <QApplication>
#include <blackmisc/context.h>
#include "server.h"
using namespace BlackMisc;
int main(int argc, char *argv[])
{
BlackMisc::CApplicationContext myApplicationContext;
QApplication a(argc, argv);
Server server;
return a.exec();
}

View File

@@ -0,0 +1,39 @@
#include <blackmisc/debug.h>
#include "server.h"
using namespace BlackMisc;
Server::Server(QObject *parent) : QObject(parent)
{
QHostAddress local = QHostAddress(QHostAddress::LocalHost);
server.Host(local, 6809);
connect(&server, SIGNAL(doMessageReceived(QString &, QByteArray&)), this, SLOT(onData(QString &, QByteArray&)));
CMessageSystem myMessageSystem;
bInfo << "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);
bAssert (test);
*test << stream;
CMessageDispatcher::getInstance().append(test);
CMessageDispatcher::getInstance().dispatch();
}
void TestMessageHandler::onTestMessage(const TestMessage *testmessage)
{
bDebug << "Message ID: " << testmessage->getID() << " with text: " << testmessage->getTestString();
}

View File

@@ -0,0 +1,32 @@
#include <blackmisc/message_system.h>
#include <blackmisc/com_server.h>
class TestMessageHandler : public BlackMisc::CMessageHandler
{
public:
TestMessageHandler()
{
registerMessageFunction(this, &TestMessageHandler::onTestMessage);
}
private:
void onTestMessage(const BlackMisc::TestMessage *testmessage);
};
class Server : public QObject
{
Q_OBJECT
public:
explicit Server(QObject *parent = NULL);
~Server();
protected slots:
void onData(QString &messageID, QByteArray& message);
private:
BlackMisc::CComServer server;
TestMessageHandler myHandler;
};