Example #1
0
MainWindow::MainWindow(QMQTT::Client *client, QWidget *parent) :
    QMainWindow(parent),
    _client(client),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    ui->conForm->init(client);
    ui->pubForm->init(client);
    ui->subForm->init(client);

    //add pushBtuoon slots
    connect(ui->pushButtonConnect,SIGNAL(clicked(bool)),this,SLOT(connectServer()));
    connect(ui->pushButtonPusblish,SIGNAL(clicked(bool)),this,SLOT(publishTopic()));
    connect(ui->pushButtonSubscribe,SIGNAL(clicked(bool)),this,SLOT(subscribeTopic()));
    connect(ui->pushButtonQuit,SIGNAL(clicked(bool)),this,SLOT(quitApp()));
    connect(ui->pushButtonClear,SIGNAL(clicked(bool)),this,SLOT(clearMsg()));
    connect(ui->pushButtonAbout,SIGNAL(clicked(bool)),this,SLOT(aboutApp()));

    //connform slots
    connect(_client, SIGNAL(disconnected()), ui->conForm, SLOT(updateUiStatus()));
    connect(_client, SIGNAL(connected()), ui->conForm, SLOT(updateUiStatus()));
    //mainwindow slots
    connect(_client, SIGNAL(connected()), this, SLOT(onMQTT_Connected()));
    connect(_client, SIGNAL(connacked(quint8)), this, SLOT(onMQTT_Connacked(quint8)));
    connect(_client, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(onMQTT_error(QAbstractSocket::SocketError)));
    connect(_client, SIGNAL(published(QMQTT::Message &)), this, SLOT(onMQTT_Published(QMQTT::Message &)));
    connect(_client, SIGNAL(pubacked(quint8, quint16)), this, SLOT(onMQTT_Pubacked(quint8, quint16)));
    connect(_client, SIGNAL(received(const QMQTT::Message &)), this, SLOT(onMQTT_Received(const QMQTT::Message &)));
    connect(_client, SIGNAL(subscribed(const QString &)), this, SLOT(onMQTT_subscribed(const QString &)));
    connect(_client, SIGNAL(subacked(quint16, quint8)), this, SLOT(onMQTT_subacked(quint16, quint8)));
    connect(_client, SIGNAL(unsubscribed(const QString &)), this, SLOT(onMQTT_unsubscribed(const QString &)));
    connect(_client, SIGNAL(unsubacked(quint16)), this, SLOT(onMQTT_unsubacked(quint16)));
    connect(_client, SIGNAL(pong()), this, SLOT(onMQTT_Pong()));
    connect(_client, SIGNAL(disconnected()), this, SLOT(onMQTT_disconnected()));
}
Example #2
0
void Client::handlePuback(quint8 type, quint16 msgid)
{
    if(type == PUBREC) {
        pd_func()->sendPuback(PUBREL, msgid);
    } else if (type == PUBREL) {
        pd_func()->sendPuback(PUBCOMP, msgid);
    }
    emit pubacked(type, msgid);
}
Example #3
0
void Client::puback(quint8 type, quint16 msgid)
{
    pd_func()->sendPuback(type, msgid);
    emit pubacked(type, msgid);
}