Skip to content

datanet-art/ofxDataNet

Repository files navigation

ofxDataNet

Native DataNet realtime pub/sub for openFrameworks. Connect an openFrameworks app to browsers, phones, Processing sketches, Python, Arduino, and other creative tools through DataNet channels.

Features

  • JSON publish and subscribe with ofJson
  • Binary messaging and a DMX frame helper
  • Background authentication and WebSocket networking
  • Heartbeat, automatic reconnect, and subscription replay
  • Structured gateway errors and authoritative presence
  • All user callbacks delivered on the openFrameworks main thread
  • No addon dependencies; networking uses openFrameworks' bundled libcurl

Compatibility

  • openFrameworks 0.12.1
  • macOS, Windows, and Linux
  • C++17

The examples and macOS CI target the latest stable openFrameworks release. The networking code uses portable openFrameworks and libcurl APIs for Windows and Linux as well. Please open an issue if you need an older OF version.

Install

Clone the addon into the addons directory of an openFrameworks installation:

cd /path/to/openFrameworks/addons
git clone https://github.com/datanet-art/ofxDataNet.git

Use the Project Generator to add ofxDataNet to an app. No other addons are required.

Quick start

#include "ofxDataNet.h"

ofxDataNet datanet;
const std::string channel = "project.your-project-id.demo";

void ofApp::setup() {
    ofxDataNetConfig config;
    config.apiKey = "ak_your_project_key";
    config.displayName = "DataNet's openFrameworks App";
    datanet.setup(config);

    datanet.onError([](const ofxDataNetError& error) {
        ofLogError("DataNet") << error.code << ": " << error.message;
    });
    datanet.subscribe(channel, [](const ofJson& data, const ofxDataNetMessageMeta& meta) {
        ofLogNotice() << meta.from << ": " << data.dump();
    });
    datanet.connect();
}

void ofApp::mousePressed(int x, int y, int button) {
    datanet.publish(channel, {{"x", x}, {"y", y}});
}

ofxDataNet listens to ofEvents().update, so callbacks arrive safely on the main thread without a manual pump call.

Examples

  • example-basic: minimal JSON publish/subscribe with mouse position
  • example-binary: publish a 512-channel DMX frame
  • example-presence: display authoritative channel occupancy

Replace the placeholder API key and channel at the top of each example before running it.

API overview

datanet.connect();
datanet.disconnect();
datanet.isConnected();

datanet.publish(channel, json);
datanet.subscribe(channel, handler);
datanet.unsubscribe(channel);

datanet.publishBinary(channel, bytes, contentType, metadata);
datanet.subscribeBinary(channel, handler);
datanet.publishDmx(channel, values);

datanet.getPresence(channel, handler);

ofxAddons

The repository follows the ofxAddons naming and layout conventions: the addon is named ofxDataNet, source lives in src/, and buildable examples use the example-* prefix. Public GitHub repositories with an ofx prefix are discovered automatically by ofxAddons; after the repository is public, an optional category request can be filed with the ofxAddons maintainers.

Release checklist

  1. Build all examples against openFrameworks 0.12.1 on at least macOS; CI also checks Linux.
  2. Tag the merged commit, for example v0.1.0, and create a GitHub release.
  3. Confirm the public repository appears on ofxAddons.

About

DataNet is developed and supported by Studio Jordan Shaw.

License

MIT

About

Native DataNet realtime pub/sub SDK for openFrameworks

Resources

License

Stars

1 star

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors