Skip to content

Latest commit

 

History

5 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

KinopioHub.cpp

简体中文 · Wiki

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.

Get started

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_basic

Variables 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

Messages and requests

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.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages