Pamoja.Mqtt
0.1.18
dotnet add package Pamoja.Mqtt --version 0.1.18
NuGet\Install-Package Pamoja.Mqtt -Version 0.1.18
<PackageReference Include="Pamoja.Mqtt" Version="0.1.18" />
<PackageVersion Include="Pamoja.Mqtt" Version="0.1.18" />
<PackageReference Include="Pamoja.Mqtt" />
paket add Pamoja.Mqtt --version 0.1.18
#r "nuget: Pamoja.Mqtt, 0.1.18"
#:package Pamoja.Mqtt@0.1.18
#addin nuget:?package=Pamoja.Mqtt&version=0.1.18
#tool nuget:?package=Pamoja.Mqtt&version=0.1.18
Pamoja.Mqtt
An MQTT client with the topic and wildcard rules, as the core transport. One capability of pamoja, one memory-safe Rust core with bindings for TypeScript, Python, and C#.
Install
dotnet add package Pamoja.Mqtt
using Pamoja.Mqtt;
This pulls in Pamoja.Native, the compiled engine, and Pamoja.Core. dotnet add package Pamoja is the whole framework in one package.
Example
The guide project's example, spliced here as it ran in CI.
From bindings/dotnet/samples/Pamoja.Guides/MqttGuide.cs:
// The broker on the site. The guide's CI runs one on localhost; point these at
// yours and nothing else changes.
const string Broker = "127.0.0.1";
const ushort Port = 1883;
// The gateway takes every temperature on the site. A `+` stands for exactly one
// level, so this matches every node's temperature and nothing deeper.
await using var gateway = new MqttClient(new MqttClientOptions
{
ClientId = "site-gateway",
Host = Broker,
Port = Port,
Qos = Qos.AtLeastOnce,
});
await gateway.ConnectAsync();
await gateway.SubscribeAsync("sensors/+/temperature");
Console.WriteLine("gateway subscribed to sensors/+/temperature");
// A node publishes under that pattern. At-least-once means the broker
// acknowledges the message, so a node knows its reading was taken.
await using var node = new MqttClient(new MqttClientOptions
{
ClientId = "node-1",
Host = Broker,
Port = Port,
Qos = Qos.AtLeastOnce,
});
await node.ConnectAsync();
await node.PublishAsync("sensors/1/temperature", "21.5");
Console.WriteLine("node published 21.5 to sensors/1/temperature");
// The gateway receives it with the topic attached, which is how it knows which
// node sent the reading without the payload having to repeat it.
MqttMessage received = (await gateway.RecvAsync())!;
Console.WriteLine(
$"gateway got {received.Text}"
+ $" on {received.Topic}");
// Disconnecting leaves the client reusable, so a node that loses its link can
// reconnect the same object when the broker comes back.
await node.DisconnectAsync();
Console.WriteLine($"node disconnected, still connected: {await node.IsConnectedAsync()}");
// A broker that is not there is reported rather than leaving a client that looks
// connected, so a retry loop has something to test.
await using var nowhere = new MqttClient(new MqttClientOptions
{
ClientId = "node-2",
Host = Broker,
Port = 1,
KeepAliveSecs = 1,
});
try
{
await nowhere.ConnectAsync();
Console.WriteLine("an unreachable broker accepted a connection, which cannot be");
}
catch (PamojaException error)
{
Console.WriteLine($"unreachable broker refused: {error.Message}");
}
The same capability in every language
| Language | Package | Reference |
|---|---|---|
| Rust | pamoja-mqtt |
reference, docs.rs, install |
| TypeScript | @pamoja/mqtt |
reference, install |
| Python | pamoja-mqtt |
reference, install |
| C# | Pamoja.Mqtt |
reference, install |
Documentation
Pamoja.Mqttreference, every type in this namespace.- The MQTT guide, with the same example in Rust, TypeScript, and Python.
- Every capability, and the install page.
License
MIT
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. 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. |
-
net8.0
- Pamoja.Core (>= 0.1.18)
- Pamoja.Native (>= 0.1.18)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on Pamoja.Mqtt:
| Package | Downloads |
|---|---|
|
Pamoja
The whole pamoja framework in one package: every capability of one memory-safe Rust core, behind an idiomatic C# facade, for IoT, robotics, and drones. |
|
|
Pamoja.Transports
Transports and testing: Reaching the network when no single link always works, and testing all of it with nothing plugged in. |
GitHub repositories
This package is not used by any popular GitHub repositories.