PubNub4Qt



  • I created a small Qt based PubNub publish/subscribe SDK.
    It's currently MSVC2012 only, QtCreator project file pull requests are welcome.
    https://github.com/doo/PubNub4Qt

    @
    int main(int argc, char *argv[]) {
    QCoreApplication a(argc, argv);

    QNetworkAccessManager networkAccessManager;
    
    QPubNubPublisher publisher(&networkAccessManager, "demo", "demo", "hello_world");
    publisher.signMessages("test");
    

    #ifdef Q_PUBNUB_CRYPT
    publisher.encryptMessages("test");
    #endif
    QTimer timer;
    timer.connect(&timer, &QTimer::timeout, [&] {
    publisher.publish(QJsonDocument::fromJson("{"msg":"hi"}").object());
    });
    timer.start(5000);

    QPubNubSubscription subscription(&networkAccessManager, "demo", "hello_world");
    

    #ifdef Q_PUBNUB_CRYPT
    subscription.decryptMessages("test");
    #endif
    subscription.subscribe();
    QObject::connect(&subscription, &QPubNubSubscription::updateReceived, [&](const QJsonArray& messages) {
    qDebug() << "Got update" << messages;
    });
    return a.exec();
    }
    @

    What you think? Usefull? Good API? Feel free to make suggestions, create issues and pull-requests on GitHub.
    Oh license is MIT, forgot to mention that on github.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.