mirror of
https://github.com/dotnet/MQTTnet.git
synced 2026-10-15 00:15:15 +08:00
23 lines
696 B
C#
23 lines
696 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 PsMqttSession Session { get; set; }
|
|
|
|
[Parameter(Mandatory = true)]
|
|
public required string Topic { get; set; }
|
|
|
|
protected override void ProcessRecord()
|
|
{
|
|
var options = new MqttClientUnsubscribeOptionsBuilder().WithTopicFilter(Topic).Build();
|
|
|
|
var response = Session.GetClient().UnsubscribeAsync(options).GetAwaiter().GetResult();
|
|
|
|
WriteObject(response);
|
|
}
|
|
} |