Expose more properties

This commit is contained in:
christian
2025-10-20 21:41:20 +02:00
parent 1114fa041d
commit 61cbaa06a8
12 changed files with 122 additions and 94 deletions
@@ -17,11 +17,19 @@ public class PublishMqttMessageCmdlet : PSCmdlet
public SwitchParameter Retain { get; set; }
[Parameter(Mandatory = true, ValueFromPipeline = true)]
public required MqttSession Session { get; set; }
public required PsMqttSession Session { get; set; }
[Parameter(Mandatory = true)]
public required string Topic { get; set; }
public string? ContentType { get; set; }
public string? ResponseTopic { get; set; }
public ushort TopicAlias { get; set; }
public uint MessageExpiryInterval { get; set; }
protected override void ProcessRecord()
{
// if (Session == null || !Session.IsConnected)
@@ -31,9 +39,13 @@ public class PublishMqttMessageCmdlet : PSCmdlet
.WithPayload(Encoding.UTF8.GetBytes(Payload ?? string.Empty))
.WithQualityOfServiceLevel((MqttQualityOfServiceLevel)QoS)
.WithRetainFlag(Retain)
.WithContentType(ContentType)
.WithResponseTopic(ResponseTopic)
.WithTopicAlias(TopicAlias)
.WithMessageExpiryInterval(MessageExpiryInterval)
.Build();
var response = Session.Client.PublishAsync(msg).GetAwaiter().GetResult();
var response = Session.GetClient().PublishAsync(msg).GetAwaiter().GetResult();
WriteObject(response);
}