A C++20 SDK for shared current JSON values, using the official NATS C client. Automatic LAN nodes, stable variable handles and RAII cleanup.
Requires CMake 3.24+, a C++20 compiler, OpenSSL and libcurl. Windows is not supported.
A Hub has one immutable namespace: kinopio::Hub hub("demo"), then hub.var("battery"). Hub() generates an isolated UUID; use Hub(std::nullopt, options) for an isolated namespace with advanced options. Use the same explicit namespace to share values. Namespaces do not provide access control. It uses wire protocol 4.
Run from this repository:
cmake -S . -B build-v3
cmake --build build-v3 -j
./build-v3/kinopio_example_watch
# In another terminal:
./build-v3/kinopio_example_basicVariables live in SDK memory. A running instance retains state while offline; when the last copy exits, its state disappears.
Installation, API, configuration and test instructions are in the Wiki.
Issues and feedback: GitHub Issues · License
kinopio::Hub hub("workshop");
hub.connected();
auto battery = hub.var("battery");
battery.set(80);
auto events = battery.sub([](const kinopio::Json &data) { /* consume data */ });
auto responder = battery.handle([battery](const kinopio::Json &) { return battery.get(0); });
battery.pub(81);
auto current = battery.req().get(); // JSON 80; the event does not change RAM state.
hub.drain();pub/sub/req forward to publish/subscribe/request. Request operations support ready(), cancel() and get(); blocking get() belongs on an application thread outside SDK callbacks. Keep subscription handles alive. get(fallback) reads one local snapshot, and watchValue observes optional JSON values. Headers, queue groups, wildcard subscriptions, bounded reply collection and deferred replies are covered in the messaging guide and C++ API.