Closed jamesbr-ashn closed 4 years ago
Good catch @jamesbr-ashn. I'm going to merge this PR to make this behavior correct but in practice, the Ping()
method isn't used in the builtin backends. The default implementation in the Backend
class in an empty method and the Discord, Slack, and Teams backends either inherit the default implemention, or also provide an empty method.
If it does end up being used, it should use the correct interval though. Thanks!
PoshBot bot ping only occurs once
Expected Behavior
According to the inline comments, the bot backend ping should occur every five seconds.
Current Behavior
The ping occurs once after 5 seconds, but only the one time.
Possible Solution
The stopwatch is being reset, not restarted. Change the command
$sw.Reset()
to$sw.Restart()
A Stopwatch instance calculates and retains the cumulative elapsed time across multiple time intervals, until the instance is reset or restarted. Use Stop to stop the current interval measurement and retain the cumulative elapsed time value. Use Reset to stop any interval measurement in progress and clear the elapsed time value. Use Restart to stop current interval measurement and start a new interval measurement.
Steps to Reproduce (for bugs)
$sw = [System.Diagnostics.Stopwatch]::StartNew()
(PoshBot.psm1, 3929)Context
I was troubleshooting a connectivity issue when I found the improper implementation. This has an unknown impact. What happens to the connection if the ping is not done periodically? The ping does not appear to be logged. Should it be?
Your Environment
Module version used: CommandType Name Version Source
Function Get-PoshBot 0.11.3 PoshBot
Function Get-PoshBotConfiguration 0.11.3 PoshBot
Function Get-PoshBotStatefulData 0.11.3 PoshBot
Function New-PoshBotCardResponse 0.11.3 PoshBot
Function New-PoshBotConfiguration 0.11.3 PoshBot
Function New-PoshBotFileUpload 0.11.3 PoshBot
Function New-PoshBotInstance 0.11.3 PoshBot
Function New-PoshBotMiddlewareHook 0.11.3 PoshBot
Function New-PoshBotScheduledTask 0.11.3 PoshBot
Function New-PoshBotSlackBackend 0.11.3 PoshBot
Function New-PoshBotTeamsBackend 0.11.3 PoshBot
Function New-PoshBotTextResponse 0.11.3 PoshBot
Function Remove-PoshBotStatefulData 0.11.3 PoshBot
Function Save-PoshBotConfiguration 0.11.3 PoshBot
Function Set-PoshBotStatefulData 0.11.3 PoshBot
Function Start-PoshBot 0.11.3 PoshBot
Function Stop-Poshbot 0.11.3 PoshBot
Operating System and PowerShell version: Windows Server 2016 (1607)
Name Value
PSVersion 5.1.14393.3053
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.14393.3053
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1