mirror of
https://github.com/dotnet/MQTTnet.git
synced 2026-10-17 01:33:03 +08:00
Fix WebSocket URI format and remove unnecessary null-forgiving operator
Co-authored-by: chkr1011 <6939810+chkr1011@users.noreply.github.com>
This commit is contained in:
co-authored by
chkr1011
parent
16f8765562
commit
9cf9a714cb
@@ -57,7 +57,7 @@ public class PublishMqttMessageCmdlet : PSCmdlet
|
||||
foreach (var key in UserProperties.Keys)
|
||||
{
|
||||
var value = UserProperties[key]?.ToString() ?? string.Empty;
|
||||
msgBuilder.WithUserProperty(key.ToString()!, value);
|
||||
msgBuilder.WithUserProperty(key.ToString(), value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ MQTTnet PowerShell Module - Quick Examples
|
||||
|
||||
3. WebSocket Connection:
|
||||
$session = New-MqttSession
|
||||
Connect-MqttSession -Session $session -WebSocketUri 'broker.hivemq.com:8000/mqtt'
|
||||
Connect-MqttSession -Session $session -WebSocketUri 'ws://broker.hivemq.com:8000/mqtt'
|
||||
Publish-MqttMessage -Session $session -Topic 'test/ws' -Payload 'Hello WS'
|
||||
|
||||
4. TLS/SSL Connection:
|
||||
|
||||
@@ -122,7 +122,7 @@ Connect-MqttSession -Session $session -Host "broker.hivemq.com" -Port 8883 `
|
||||
|
||||
**WebSocket Connection:**
|
||||
```powershell
|
||||
Connect-MqttSession -Session $session -WebSocketUri "broker.hivemq.com:8000/mqtt"
|
||||
Connect-MqttSession -Session $session -WebSocketUri "ws://broker.hivemq.com:8000/mqtt"
|
||||
```
|
||||
|
||||
**With Authentication:**
|
||||
|
||||
@@ -78,7 +78,7 @@ Write-Host "`nTesting WebSocket connection..." -ForegroundColor Yellow
|
||||
$wsSession = New-MqttSession
|
||||
|
||||
try {
|
||||
Connect-MqttSession -Session $wsSession -WebSocketUri "broker.hivemq.com:8000/mqtt"
|
||||
Connect-MqttSession -Session $wsSession -WebSocketUri "ws://broker.hivemq.com:8000/mqtt"
|
||||
Write-Host "Connected via WebSocket!" -ForegroundColor Green
|
||||
|
||||
Publish-MqttMessage -Session $wsSession -Topic "test/websocket" -Payload "Hello via WebSocket!"
|
||||
|
||||
Reference in New Issue
Block a user