mirror of
https://github.com/dotnet/MQTTnet.git
synced 2026-10-16 01:03:01 +08:00
21 lines
590 B
C#
21 lines
590 B
C#
using System.Management.Automation;
|
|
|
|
namespace MQTTnet.PowerShell.Cmdlets;
|
|
|
|
[Cmdlet("Unsubscribe", "MqttTopic")]
|
|
[OutputType(typeof(MqttClientUnsubscribeResult))]
|
|
public class UnsubscribeMqttTopicCmdlet : PSCmdlet
|
|
{
|
|
[Parameter(Mandatory = true, ValueFromPipeline = true)]
|
|
public required MqttSession Session { get; set; }
|
|
|
|
[Parameter(Mandatory = true)]
|
|
public required string Topic { get; set; }
|
|
|
|
protected override void ProcessRecord()
|
|
{
|
|
var response = Session.Client.UnsubscribeAsync(Topic).GetAwaiter().GetResult();
|
|
|
|
WriteObject(response);
|
|
}
|
|
} |