Moryx.AbstractionLayer.Resources.Mqtt.Endpoints
10.10.1
dotnet add package Moryx.AbstractionLayer.Resources.Mqtt.Endpoints --version 10.10.1
NuGet\Install-Package Moryx.AbstractionLayer.Resources.Mqtt.Endpoints -Version 10.10.1
<PackageReference Include="Moryx.AbstractionLayer.Resources.Mqtt.Endpoints" Version="10.10.1" />
<PackageVersion Include="Moryx.AbstractionLayer.Resources.Mqtt.Endpoints" Version="10.10.1" />
<PackageReference Include="Moryx.AbstractionLayer.Resources.Mqtt.Endpoints" />
paket add Moryx.AbstractionLayer.Resources.Mqtt.Endpoints --version 10.10.1
#r "nuget: Moryx.AbstractionLayer.Resources.Mqtt.Endpoints, 10.10.1"
#:package Moryx.AbstractionLayer.Resources.Mqtt.Endpoints@10.10.1
#addin nuget:?package=Moryx.AbstractionLayer.Resources.Mqtt.Endpoints&version=10.10.1
#tool nuget:?package=Moryx.AbstractionLayer.Resources.Mqtt.Endpoints&version=10.10.1
ResourceRpcEndpoint
Endpoint to remote call a procedure/method on a resource.
Setup :
When run your project for the first time a configuration file will be generated inside the default MORYX Config folder. The content will be as follows:
{ "Id": "my-id", "Host": "localhost", "Port": 1883, "Username": "", "Password": "", "Tls": false, "QoS": "ExactlyOnce", // check the MqttQualityOfServiceLevel enum for more info "ReconnectDelayMs": 30000, "ReconnectWithClientSession": false, "RootTopic": "" }// Program.cs builder.Services.AddMqttClient().AddMqttEndpoints(); // <-- this add supports for the endpointsAvailable Endpoint topics :
[root topic of the endpoint client]/resources/{identifier}/invoke/{methodName}, example:moryx/device-2/resources/123654/invoke/ChangeCapabilitiesIf no root topic was configured the topic becomes
resources/{identifier}/invoke/{methodName}, example:resources/123654/invoke/ChangeCapabilitiesIf the method you are invoking has parameters, you should put the value of those parameters in your payload:
// MyResource.cs //code.. public void MyMethod(int testResult, string name) { //code.. } //code..Given the previous method your json
payloadshould look like the following:{ "TestResult": 564, "Name": "DefaultName" }Response Topic :
In MQTT v5+ you can specify a response topic in your message. If a response topic is present the endpoint will sent the response of the invocation to that topic. If a response topic was not defined the default response topic will have the structure
resources/{identifier}/invoked/{methodName}. Here is an example:resources/123654/invoked/ChangeCapabilitiesResponse Payload :
If the method you are calling has a return value:
// MyResource.cs //code.. public int MyMethod(int testResult, string name) { //code.. return 10; } //code..Given a method like above the endpoint will sent the result back to the client. The schema of the json
payloadwill look like the following:{ "Value": 10, "ValueType": 4 // check EntryValueType for more infos }
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. 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. |
-
net10.0
- Microsoft.Extensions.Logging (>= 10.0.11)
- Moryx.AbstractionLayer (>= 10.10.1)
- Moryx.AspNetCore.Mqtt (>= 10.10.1)
- Moryx.Runtime (>= 10.10.1)
- MQTTnet (>= 5.0.1.1416)
- Newtonsoft.Json (>= 13.0.4)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.