mirror of
https://github.com/dotnet/MQTTnet.git
synced 2026-10-18 18:43:10 +08:00
Add Test-MqttConnection and Show-MqttExamples cmdlets, update documentation
Co-authored-by: chkr1011 <6939810+chkr1011@users.noreply.github.com>
This commit is contained in:
co-authored by
chkr1011
parent
07b72e75ed
commit
16f8765562
@@ -88,6 +88,15 @@ Remove-MqttSession -Session $session
|
||||
|
||||
## Available Cmdlets
|
||||
|
||||
### Help and Examples
|
||||
|
||||
#### Show-MqttExamples
|
||||
Displays quick examples for common MQTT tasks.
|
||||
|
||||
```powershell
|
||||
Show-MqttExamples
|
||||
```
|
||||
|
||||
### Session Management
|
||||
|
||||
#### New-MqttSession
|
||||
@@ -174,6 +183,18 @@ Disposes the MQTT session and releases resources.
|
||||
Remove-MqttSession -Session $session
|
||||
```
|
||||
|
||||
#### Test-MqttConnection
|
||||
Tests if the MQTT connection is alive by sending a PING packet.
|
||||
|
||||
```powershell
|
||||
$isAlive = Test-MqttConnection -Session $session -TimeoutSeconds 5
|
||||
Write-Host "Connection is alive: $isAlive"
|
||||
```
|
||||
|
||||
**Parameters:**
|
||||
- `Session`: The MQTT session (mandatory)
|
||||
- `TimeoutSeconds`: Timeout for the ping operation (default: 5)
|
||||
|
||||
### Publishing
|
||||
|
||||
#### Publish-MqttMessage
|
||||
|
||||
Reference in New Issue
Block a user