Java SDK: JNI bindings to libquicproquo_ffi with QpqClient class, Gradle build, and exception hierarchy matching Kotlin SDK. Ruby SDK: FFI gem wrapping libquicproquo_ffi with Client class, block-form auto-disconnect, gemspec for RubyGems publishing, and example script.
51 lines
1.3 KiB
Markdown
51 lines
1.3 KiB
Markdown
# QuicProQuo Java SDK
|
|
|
|
Java wrapper over `libquicproquo_ffi` via JNI for JVM and Android.
|
|
|
|
## Prerequisites
|
|
|
|
- JDK 17+
|
|
- `libquicproquo_ffi` built for the target platform
|
|
- JNI bridge compiled (shared with Kotlin SDK: `../kotlin/jni/`)
|
|
|
|
## Building
|
|
|
|
```sh
|
|
# Build Rust FFI library
|
|
cargo build --release -p quicproquo-ffi
|
|
|
|
# Build Java SDK
|
|
./gradlew build
|
|
```
|
|
|
|
## Usage
|
|
|
|
```java
|
|
import dev.quicproquo.QpqClient;
|
|
|
|
try (QpqClient client = new QpqClient("127.0.0.1:5001", "ca.pem")) {
|
|
client.login("alice", "secret");
|
|
client.send("bob", "hello".getBytes());
|
|
|
|
var messages = client.receive(5000);
|
|
messages.forEach(msg -> System.out.println("Received: " + msg));
|
|
}
|
|
```
|
|
|
|
## API
|
|
|
|
| Method | Description |
|
|
|---|---|
|
|
| `new QpqClient(server, caCertPath)` | Connect to server |
|
|
| `client.login(username, password)` | OPAQUE authentication |
|
|
| `client.send(recipient, message)` | Send message by username |
|
|
| `client.receive(timeoutMs)` | Receive pending messages |
|
|
| `client.close()` / `client.disconnect()` | Disconnect |
|
|
| `client.isConnected()` | Connection status |
|
|
|
|
## Structure
|
|
|
|
- `src/main/java/dev/quicproquo/QpqClient.java` -- High-level client
|
|
- `src/main/java/dev/quicproquo/NativeBridge.java` -- JNI declarations
|
|
- JNI C bridge shared with Kotlin SDK at `../kotlin/jni/`
|