mirror of
https://github.com/dotnet/MQTTnet.git
synced 2026-10-20 03:24:33 +08:00
Expose more properties
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user