void MQTT::initializeConnection() { //Init UDP DEBUG; if(m_host.isEmpty() || !m_port || m_topic.isEmpty()) { DEBUG << "Please define a host and a port and a topic"; //disconnect(); return; } this->client = new QMQTT::Client(m_host, m_port); this->client->setClientId(QString(QUuid::createUuid().toString())); // this->client->setUsername("user"); // this->client->setPassword("password"); this->client->connect(); QObject::connect(this->client, SIGNAL(received(const QMQTT::Message&)), this, SLOT(processReceivedMessage(const QMQTT::Message&))); QObject::connect(this->client, SIGNAL(connacked(quint8)), this, SLOT(subscribeToTopic(quint8))); QObject::connect(this->client, SIGNAL(subscribed(QString)), this, SLOT(subscribedToTopic(QString))); QObject::connect(this->client, SIGNAL(disconnected()), this, SIGNAL(disconnected())); QObject::connect(this->client, SIGNAL(connected()), this, SIGNAL(connected())); }
int main(int argc, const char** argv) { printf("Solace OpenMAMA tutorial.\nReceiving messages with OpenMAMA.\n"); // set Ctrl-C handler signal(SIGINT, stopHandler); initializeBridge("solace"); connectTransport("vmr"); // see mama.properties subscribeToTopic("tutorial.topic"); // receive messages until Ctrl-C is pressed mama_status status; if ((status = mama_start(global.bridge)) != MAMA_STATUS_OK) { printf("OpenMAMA start error: %s\n", mamaStatus_stringForStatus(status)); } // normal exit after Ctrl-C was pressed printf("Closing OpenMAMA\n"); mama_close(); exit(status); }