{"id":14982662,"url":"https://github.com/pkoretic/qt-nats","last_synced_at":"2025-08-18T17:13:36.265Z","repository":{"id":16030516,"uuid":"79146266","full_name":"pkoretic/qt-nats","owner":"pkoretic","description":"A C++11 nats client written in Qt","archived":false,"fork":false,"pushed_at":"2022-12-27T15:00:21.000Z","size":52,"stargazers_count":38,"open_issues_count":0,"forks_count":16,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-08-13T13:54:04.734Z","etag":null,"topics":["cpp","nats","qt","qt5","qt6"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pkoretic.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-01-16T18:24:31.000Z","updated_at":"2025-04-24T06:55:19.000Z","dependencies_parsed_at":"2023-01-11T20:24:22.599Z","dependency_job_id":null,"html_url":"https://github.com/pkoretic/qt-nats","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/pkoretic/qt-nats","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pkoretic%2Fqt-nats","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pkoretic%2Fqt-nats/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pkoretic%2Fqt-nats/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pkoretic%2Fqt-nats/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pkoretic","download_url":"https://codeload.github.com/pkoretic/qt-nats/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pkoretic%2Fqt-nats/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271027687,"owners_count":24687082,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-18T02:00:08.743Z","response_time":89,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cpp","nats","qt","qt5","qt6"],"created_at":"2024-09-24T14:05:49.503Z","updated_at":"2025-08-18T17:13:36.238Z","avatar_url":"https://github.com/pkoretic.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# qt-nats\n\nA [Qt](https://www.qt.io) C++11 client for the [NATS messaging system](https://nats.io).\n\n[![License MIT](https://cdn.rawgit.com/pkoretic/qt-nats/badges/license.svg)](http://opensource.org/licenses/MIT)\n[![Language (C++)](https://cdn.rawgit.com/pkoretic/qt-nats/badges/powered_by-C%2B%2B-blue.svg)](http://en.cppreference.com/w/cpp/language)\n\n## Installation\n\nThis is a header-only library that depends on Qt. All you have to do is to include a copy of `natsclient.h` to your\nproject sources directory, making sure the Qt `Network` module is properly linking to your application(s). Follow the instructions below according to your project's build system.\n\n\n### CMake\n\nIn your project's `CMakeLists.txt`:\n\n```\n# Add Network module\nfind_package(Qt${QT_VERSION_MAJOR} COMPONENTS Network REQUIRED)\n\n# Add natsclient.h to the project's sources\nset(PROJECT_SOURCES\n        main.cpp\n        dialog.cpp\n        dialog.h\n        dialog.ui\n        resources.qrc\n        # ... other source files\n        # ...\n        natsclient.h  # \u003c--- Add this line\n)\n\n# Link Network module\ntarget_link_libraries(MensajeroSMS PRIVATE  Qt${QT_VERSION_MAJOR}::Network)\n\n```\n\n\n### QMake\n\nFor QMake projects, you need to add the `network` module to your `project-name.pro` file (```QT += network```).\n\n\n\nFor more information see **[examples](examples)**.\n\n```\n#include \u003cQCoreApplication\u003e\n#include \"natsclient.h\"\n\nint main(int argc, char *argv[])\n{\n    QCoreApplication app(argc, argv);\n\n    Nats::Client client;\n    client.connect(\"127.0.0.1\", 4222, [\u0026]\n    {\n        // simple subscribe\n        client.subscribe(\"foo\", [](QString message, QString inbox, QString subject)\n        {\n            qDebug() \u003c\u003c \"received: \" \u003c\u003c message \u003c\u003c inbox \u003c\u003c subject;\n        });\n\n        // simple publish\n        client.publish(\"foo\", \"Hello NATS!\");\n    });\n\n    return app.exec();\n}\n```\n\n## Basic usage\n\n```\nNats::Client client;\nclient.connect(\"127.0.0.1\", 4222, [\u0026]\n{\n    // simple publish\n    client.publish(\"foo\", \"Hello World!\");\n\n    // simple subscribe\n    client.subscribe(\"foo\", [](QString message, QString /* inbox */, QString /* subject */)\n    {\n        qDebug() \u003c\u003c \"received message: \" \u003c\u003c message;\n    });\n\n    // unsubscribe\n    int sid = client.subscribe(\"foo\", [](QString, QString, QString){});\n    client.unsubscribe(sid);\n\n    // request\n    client.request(\"help\", [\u0026](QString /* message */, QString reply_inbox, QString /* subject */)\n    {\n        client.publish(reply_inbox, \"I can help\");\n    });\n});\n```\n\n\n## Queue Groups\n\nAll subscriptions with the same queue name will form a queue group. Each\nmessage will be delivered to only one subscriber per queue group, queuing\nsemantics. You can have as many queue groups as you wish.  Normal subscribers\nwill continue to work as expected.\n\n```\nclient.subscribe(\"foo\", \"job.workers\", [](QString message, QString reply_inbox, QString subject)\n{\n    qDebug().noquote() \u003c\u003c \"received message:\" \u003c\u003c message \u003c\u003c subject \u003c\u003c reply_inbox;\n});\n```\n\n## Authentication\n\n```\nNats::Client client;\nNats::Options options;\n\n// username/password\noptions.user = \"user\";\noptions.pass = \"pass\";\n\nclient.connect(\"127.0.0.1\", 4222, options, []\n{\n    ...\n});\n\n// token\noptions.token = \"mytoken\";\n\nclient.connect(\"127.0.0.1\", 4222, options, []\n{\n    ...\n});\n\n```\n\n## TLS/SSL\n```\nNats::Client client;\nNats::Options options;\n\n// for development\noptions.ssl_verify = false;\n\n// set relevant ssl options\noptions.ssl_ca = \"/path/to/ca.crt\";\noptions.ssl_key = \"/path/to/local.key\";\noptions.ssl_cert = \"/path/to/local.crt\";\n\nclient.connect(\"127.0.0.1\", 4222, options, [\u0026client]\n{\n    ...\n});\n```\n\n## Qt signals\n\nThis is Qt specific. If you are used to using Qt signals \u0026 slots or you just prefer them over callbacks:\n\n```\nNats::Client client;\n\nQObject::connect(\u0026client, \u0026Nats::Client::connected, [\u0026client]\n{\n    Nats::Subscription *s = client.subscribe(\"foo\");\n    QObject::connect(s, \u0026Nats::Subscription::received, [s]\n    {\n        qDebug().noquote() \u003c\u003c \"received message:\" \u003c\u003c s-\u003emessage \u003c\u003c s-\u003esubject \u003c\u003c s-\u003einbox;\n        s-\u003edeleteLater();\n    });\n\n    client.publish(\"foo\", \"Hello NATS!\");\n});\n\nclient.connect(\"127.0.0.1\", 4222);\n```\n\n## Errors and signals\n\nCatch errors:\n```\nQObject::connect(\u0026client, \u0026Nats::Client::error, [](const QString \u0026error)\n{\n    qDebug() \u003c\u003c error;\n});\n\n```\n\nCatch connection disconnect:\n```\nQObject::connect(\u0026client, \u0026Nats::Client::disconnected, []\n{\n    qDebug() \u003c\u003c \"disconnected\";\n});\n\n```\n\n## Debug mode\n\nFor extra debug information env variable can be used:\n\n```\nexport DEBUG=qt-nats\n```\nor\n\n```\nDEBUG=qt-nats ./program\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpkoretic%2Fqt-nats","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpkoretic%2Fqt-nats","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpkoretic%2Fqt-nats/lists"}