| | | 1 | | <# |
| | | 2 | | .SYNOPSIS |
| | | 3 | | Gets the number of connected SignalR clients. |
| | | 4 | | .DESCRIPTION |
| | | 5 | | This function retrieves the current number of connected SignalR clients from the IConnectionTracker service. |
| | | 6 | | It can be used to monitor the number of active connections to the SignalR hub. |
| | | 7 | | .PARAMETER Server |
| | | 8 | | The Kestrun server instance. If not specified, the default server is used. |
| | | 9 | | .EXAMPLE |
| | | 10 | | Get-KrSignalRConnectedClient |
| | | 11 | | Retrieves the number of connected SignalR clients from the default Kestrun server. |
| | | 12 | | .EXAMPLE |
| | | 13 | | Get-KrServer | Get-KrSignalRConnectedClient |
| | | 14 | | Retrieves the number of connected SignalR clients using the pipeline. |
| | | 15 | | .NOTES |
| | | 16 | | This function requires that SignalR has been configured on the server using Add-KrSignalR |
| | | 17 | | #> |
| | | 18 | | function Get-KrSignalRConnectedClient { |
| | | 19 | | [KestrunRuntimeApi('Everywhere')] |
| | | 20 | | [CmdletBinding()] |
| | | 21 | | [outputtype([System.Nullable`1[System.Int32]])] |
| | | 22 | | param( |
| | | 23 | | [Parameter(Mandatory = $false, ValueFromPipeline = $true)] |
| | | 24 | | [Kestrun.Hosting.KestrunHost]$Server |
| | | 25 | | ) |
| | | 26 | | begin { |
| | | 27 | | # Ensure the server instance is resolved |
| | 0 | 28 | | $Server = Resolve-KestrunServer -Server $Server |
| | | 29 | | } |
| | | 30 | | process { |
| | 0 | 31 | | return [Kestrun.Hosting.KestrunHostSignalRExtensions]::GetConnectedClientCount($Server) |
| | | 32 | | } |
| | | 33 | | } |