Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: CI

on:
push:
branches: [main]
pull_request:

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-java@v5
with:
distribution: temurin
java-version: 17
- uses: gradle/actions/setup-gradle@v4
with:
gradle-version: '8.5'
- run: gradle clean buildReleaseArtifacts
39 changes: 39 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Documentation

on:
push:
branches: [main]
workflow_dispatch:

permissions:
contents: read
pages: write
id-token: write

concurrency:
group: pages
cancel-in-progress: true

jobs:
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-java@v5
with:
distribution: temurin
java-version: 17
- uses: gradle/actions/setup-gradle@v4
with:
gradle-version: '8.5'
- run: gradle javadoc
- uses: actions/configure-pages@v5
- uses: actions/upload-pages-artifact@v3
with:
path: build/docs/javadoc
- name: Deploy
id: deployment
uses: actions/deploy-pages@v4
28 changes: 28 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Release

on:
push:
tags: ['v*']

jobs:
release:
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-java@v5
with:
distribution: temurin
java-version: 17
- uses: gradle/actions/setup-gradle@v4
with:
gradle-version: '8.5'
- name: Build release artifacts
run: gradle -PgithubReleaseTag=${GITHUB_REF_NAME} buildReleaseArtifacts
- uses: softprops/action-gh-release@v2
with:
files: |
release/DataNet.txt
release/DataNet.zip
release/DataNet.pdex
29 changes: 11 additions & 18 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,24 +1,17 @@
# Compiled class file
.gradle/
build/
release/
library.properties
.idea/
.vscode/
*.iml
*.class

# Log file
*.log

# BlueJ files
*.ctxt

# Mobile Tools for Java (J2ME)
.mtj.tmp/

# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
*.pdex
.DS_Store
hs_err_pid*
replay_pid*

!gradle/wrapper/gradle-wrapper.jar
124 changes: 115 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,123 @@
# datanet-processing
DataNet Processing library — realtime pub/sub for sketches, visualizations, and installations.
# DataNet for Processing

Realtime pub/sub for networked sketches, visualizations, and installations. The library connects Processing 4 sketches to DataNet channels using the same protocol as the JavaScript, Python, and Arduino SDKs.

## Features

- JSON publish and subscribe with Processing `JSONObject` and `JSONArray`
- Binary messages plus DMX frame helpers
- Automatic authentication, heartbeat, reconnect, and subscription replay
- Structured gateway errors
- Authoritative channel presence
- Message and event callbacks delivered on Processing's animation thread
- No runtime dependencies beyond Processing 4 and Java 17

## Install

Once the library is accepted into Processing Contributions, install it from **Sketch → Import Library… → Manage Libraries…** and search for **DataNet**.

Until then, download `DataNet.zip` from the latest GitHub release, unzip it into your Processing sketchbook's `libraries` directory, and restart Processing. The final path should be:

```text
<sketchbook>/libraries/DataNet/library/DataNet.jar
```

## Quick start

```java
import art.datanet.*;
import processing.data.JSONObject;

String API_KEY = "ak_your_project_key";
String CHANNEL = "project.your-project-id.demo";
DataNet datanet;

void setup() {
size(720, 480);

datanet = new DataNet(this, DataNetConfig.builder(API_KEY)
.displayName("DataNet's Processing Sketch")
.build());

datanet.onError(error -> println(error.code() + ": " + error.getMessage()));
datanet.subscribe(CHANNEL, (data, meta) -> println(data));
datanet.connect();
}

void mousePressed() {
JSONObject message = new JSONObject();
message.setFloat("x", mouseX);
message.setFloat("y", mouseY);
datanet.publish(CHANNEL, message);
}
```

Open **File → Examples → Contributed Libraries → DataNet** for complete JSON, binary/DMX, and presence examples.

## API overview

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

datanet.publish(channel, jsonValue);
datanet.subscribe(channel, (data, meta) -> { });
datanet.unsubscribe(channel);

datanet.publishBinary(channel, bytes);
datanet.publishBinary(channel, bytes, "binary/custom", metadata);
datanet.subscribeBinary(channel, (bytes, meta) -> { });
datanet.publishDmx(channel, values);

datanet.getPresence(channel, presence -> println(presence.occupancy()));
```

`MessageMeta` includes `channel`, `from`, and `timestamp`. `BinaryMessageMeta` also includes `contentType`, byte count, and optional protocol metadata.

## Build and test

Processing 4 ships with Java 17. If Java 17 is available in your shell:

```sh
./gradlew clean test
./gradlew buildReleaseArtifacts
```

On macOS, you can use Processing's bundled JDK:

```sh
JAVA_HOME=/Applications/Processing.app/Contents/app/resources/jdk ./gradlew clean buildReleaseArtifacts
```

Release artifacts are written to `release/DataNet.zip`, `release/DataNet.txt`, and `release/DataNet.pdex`. To install a development build directly into the local sketchbook, run:

```sh
./gradlew deployToProcessingSketchbook
```

## Releasing

1. Update `prettyVersion` and increment the integer `version` in `release.properties`.
2. Run `./gradlew clean buildReleaseArtifacts`.
3. Tag the merged commit, for example `v0.1.0`, and push the tag.
4. GitHub Actions creates the release and attaches the `.zip`, `.txt`, and `.pdex` files required by Processing Contributions.
5. For the first release, submit the stable `DataNet.txt` URL to the Processing Contributions repository. Later releases are discovered through the incremented metadata.

## Compatibility

- Processing 4
- macOS, Windows, and Linux
- DataNet protocol: JSON and base64 binary WebSocket envelopes

## About

DataNet is developed and supported by [Studio Jordan Shaw](https://www.jordanshaw.com), a creative technology studio building tools for realtime, networked, and physical-digital work.

- DataNet: [datanet.art](https://datanet.art)
- Studio: [jordanshaw.com](https://www.jordanshaw.com)
- Instagram: [@jshaw3](https://www.instagram.com/jshaw3)
- GitHub: [datanet-art](https://github.com/datanet-art)
- Source: [datanet-processing](https://github.com/datanet-art/datanet-processing)
- Examples: [datanet-examples](https://github.com/datanet-art/datanet-examples)
- [DataNet](https://datanet.art)
- [GitHub organization](https://github.com/datanet-art)
- [Cross-platform examples](https://github.com/datanet-art/datanet-examples)

## License

MIT
[MIT](LICENSE)
Loading
Loading