ZenohDotNet.Native 0.1.0

dotnet add package ZenohDotNet.Native --version 0.1.0
                    
NuGet\Install-Package ZenohDotNet.Native -Version 0.1.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="ZenohDotNet.Native" Version="0.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ZenohDotNet.Native" Version="0.1.0" />
                    
Directory.Packages.props
<PackageReference Include="ZenohDotNet.Native" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add ZenohDotNet.Native --version 0.1.0
                    
#r "nuget: ZenohDotNet.Native, 0.1.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package ZenohDotNet.Native@0.1.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=ZenohDotNet.Native&version=0.1.0
                    
Install as a Cake Addin
#tool nuget:?package=ZenohDotNet.Native&version=0.1.0
                    
Install as a Cake Tool

ZenohDotNet.Native

Low-level Zenoh FFI bindings for .NET with embedded runtime.

Overview

ZenohDotNet.Native provides P/Invoke bindings to the Zenoh C library, allowing .NET applications to use Zenoh's distributed messaging capabilities. The native Zenoh runtime is embedded in the NuGet package, so no separate installation is required.

Features

  • Embedded Runtime: Zenoh C library is included in the package
  • Cross-Platform: Supports Windows, Linux, and macOS on x64 and ARM64
  • Mobile Support: Android (arm64-v8a, armeabi-v7a, x86_64) and iOS (arm64)
  • Memory Safe: Proper IDisposable implementation for resource management
  • .NET Standard 2.1: Compatible with .NET Core 3.0+, .NET 5+, and Unity 2021.2+
  • Liveliness API: Monitor resource presence with liveliness tokens
  • Attachments: Send key-value metadata alongside payloads

Supported Platforms

  • Windows (x64, ARM64)
  • Linux (x64, ARM64)
  • macOS (x64, ARM64)
  • Android (arm64-v8a, armeabi-v7a, x86_64)
  • iOS (arm64)

Installation

dotnet add package ZenohDotNet.Native

Usage

Creating a Session

using ZenohDotNet.Native;

// Open a session with default configuration
using var session = new Session();

// Or with custom JSON configuration
var config = "{\"mode\":\"peer\"}";
using var session = new Session(config);

Publishing Data

using var session = new Session();
using var publisher = session.DeclarePublisher("demo/example/test");

// Publish a string
publisher.Put("Hello, Zenoh!");

// Publish bytes
byte[] data = { 1, 2, 3, 4 };
publisher.Put(data);

// Publish with encoding
publisher.Put(data, PayloadEncoding.ApplicationJson);

Publishing with Attachments

// Attachments are key-value metadata sent alongside the payload
var attachment = new Dictionary<string, string>
{
    ["sender"] = "device-001",
    ["priority"] = "high"
};
session.Put("demo/example/test", "Hello!", attachment);

Subscribing to Data

using var session = new Session();
using var subscriber = session.DeclareSubscriber("demo/example/**", sample =>
{
    Console.WriteLine($"Received on {sample.KeyExpression}: {sample.GetPayloadAsString()}");
});

// Keep the application running to receive messages
Console.ReadLine();

Query/Queryable (Request-Response)

// Queryable (server)
using var queryable = session.DeclareQueryable("demo/query", query =>
{
    Console.WriteLine($"Query received: {query.Selector}");
    query.Reply("demo/query", "Response data");
});

// Query (client)
session.Get("demo/query", sample =>
{
    Console.WriteLine($"Reply: {sample.GetPayloadAsString()}");
});

Liveliness API

Monitor resource presence using liveliness tokens:

// Declare a liveliness token (resource is "alive" while token exists)
using var token = session.DeclareLivelinessToken("my/resource/path");

// Subscribe to liveliness changes
using var liveSub = session.DeclareLivelinessSubscriber("my/**", (keyExpr, isAlive) =>
{
    if (isAlive)
        Console.WriteLine($"{keyExpr} is now alive");
    else
        Console.WriteLine($"{keyExpr} has died");
});

Delete

// Delete a key expression
session.Delete("demo/example/test");

API Reference

Session

  • Session() - Opens a session with default configuration
  • Session(string configJson) - Opens a session with JSON configuration
  • DeclarePublisher(string keyExpr) - Creates a publisher
  • DeclarePublisher(string keyExpr, PublisherOptions options) - Creates a publisher with options
  • DeclareSubscriber(string keyExpr, Action<Sample> callback) - Creates a subscriber
  • DeclareQueryable(string keyExpr, Action<Query> callback) - Creates a queryable
  • DeclareQuerier(string keyExpr) - Creates a querier for repeated queries
  • Get(string selector, Action<Sample> callback) - Performs a query
  • Put(string keyExpr, byte[] data) - Direct put without publisher
  • Put(string keyExpr, byte[] data, IDictionary<string, string> attachment) - Put with attachment
  • Delete(string keyExpr) - Delete a key expression
  • DeclareLivelinessToken(string keyExpr) - Declare a liveliness token
  • DeclareLivelinessSubscriber(string keyExpr, Action<string, bool> callback) - Subscribe to liveliness changes
  • GetZenohId() - Gets the session's Zenoh ID

Publisher

  • Put(byte[] data) - Publishes binary data
  • Put(string value) - Publishes a UTF-8 string
  • Put(byte[] data, PayloadEncoding encoding) - Publishes with encoding
  • KeyExpression - Gets the key expression

Subscriber

  • Automatically receives data via callback
  • Callback receives Sample objects

Sample

  • KeyExpression - The key expression of the sample
  • Payload - Raw byte array payload
  • Kind - Sample kind (Put or Delete)
  • Encoding - Payload encoding
  • Timestamp - Optional timestamp
  • GetPayloadAsString() - Converts payload to UTF-8 string

Query

  • Selector - The query selector
  • Payload - Optional query payload
  • Reply(string keyExpr, byte[] data) - Reply to the query
  • Reply(string keyExpr, string value) - Reply with a string

LivelinessToken

  • KeyExpression - The token's key expression
  • Disposing the token signals the resource is no longer alive

LivelinessSubscriber

  • Receives (string keyExpr, bool isAlive) callbacks
  • isAlive = true when a token is declared
  • isAlive = false when a token is dropped

Building from Source

See the main repository README for build instructions.

License

This project is licensed under the MIT License.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.1

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on ZenohDotNet.Native:

Package Downloads
ZenohDotNet.Client

MIT-licensed high-level async Zenoh client for .NET 8.0+. Depends on ZenohDotNet.Native, which bundles Zenoh native binaries licensed under Apache-2.0.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.1.0 56 2/2/2026