< Summary - Kestrun — Combined Coverage

Information
Class: Public.SignalR.Send-KrSignalRGroupMessage
Assembly: Kestrun.PowerShell.Public
File(s): /home/runner/work/Kestrun/Kestrun/src/PowerShell/Kestrun/Public/SignalR/Send-KrSignalRGroupMessage.ps1
Tag: Kestrun/Kestrun@2d87023b37eb91155071c91dd3d6a2eeb3004705
Line coverage
0%
Covered lines: 0
Uncovered lines: 12
Coverable lines: 12
Total lines: 69
Line coverage: 0%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Coverage history

Coverage history 0 25 50 75 100 10/15/2025 - 21:27:26 Line coverage: 0% (0/12) Total lines: 69 Tag: Kestrun/Kestrun@c33ec02a85e4f8d6061aeaab5a5e8c3a8b665594

Metrics

File(s)

/home/runner/work/Kestrun/Kestrun/src/PowerShell/Kestrun/Public/SignalR/Send-KrSignalRGroupMessage.ps1

#LineLine coverage
 1<#
 2    .SYNOPSIS
 3        Broadcasts a message to a specific SignalR group.
 4    .DESCRIPTION
 5        This function sends a message to all clients in a specific SignalR group via the IRealtimeBroadcaster service.
 6        The message is broadcast in real-time to all connected clients listening in the specified group.
 7    .PARAMETER GroupName
 8        The name of the group to broadcast to.
 9    .PARAMETER Method
 10        The hub method name to invoke on clients.
 11    .PARAMETER Message
 12        The message to broadcast to the group.
 13    .PARAMETER Server
 14        The Kestrun server instance. If not specified, the default server is used.
 15    .EXAMPLE
 16        Send-KrSignalRGroupMessage -GroupName "Admins" -Method "ReceiveAdminUpdate" -Message @{ Update = "System mainten
 17        Broadcasts an admin update to all clients in the "Admins" group.
 18    .EXAMPLE
 19        Send-KrSignalRGroupMessage -GroupName "Workers" -Method "ReceiveTaskUpdate" -Message @{ TaskId = 123; Progress =
 20        Broadcasts a task progress update to all clients in the "Workers" group.
 21    .NOTES
 22        This function requires that SignalR has been configured on the server using Add-KrSignalRHubMiddleware.
 23        The IRealtimeBroadcaster service must be registered for this cmdlet to work.
 24#>
 25function Send-KrSignalRGroupMessage {
 26    [KestrunRuntimeApi('Everywhere')]
 27    [CmdletBinding()]
 28    param(
 29        [Parameter(Mandatory = $true)]
 30        [string]$GroupName,
 31
 32        [Parameter(Mandatory = $true)]
 33        [string]$Method,
 34
 35        [Parameter(Mandatory = $true)]
 36        [object]$Message,
 37
 38        [Parameter(ValueFromPipeline)]
 39        [Kestrun.Hosting.KestrunHost]$Server
 40    )
 41
 42    process {
 43        try {
 044            if ($null -ne $Context) {
 045                if ($Context.BroadcastToGroup($GroupName, $Method, $Message, [System.Threading.CancellationToken]::None)
 046                    Write-KrLog -Level Debug -Message "Broadcasted to group '$GroupName' via method '$Method': $Message"
 47                    return
 48                } else {
 049                    Write-KrLog -Level Error -Message "Failed to broadcast to group '$GroupName': Unknown error"
 50                    return
 51                }
 52            }
 53
 54            # Fallback: allow explicit host usage outside a route (no HttpContext)
 055            if (-not $Server) {
 056                try { $Server = Get-KrServer } catch { $Server = $null }
 57            }
 058            if ($null -ne $Server) {
 059                $task = [Kestrun.Hosting.KestrunHostSignalRExtensions]::BroadcastToGroupAsync($Server, $GroupName, $Meth
 060                $null = $task.GetAwaiter().GetResult()
 061                Write-KrLog -Level Debug -Message "Broadcasted to group '$GroupName' via method '$Method' (host fallback
 62            } else {
 063                Write-KrOutsideRouteWarning
 64            }
 65        } catch {
 066            Write-KrLog -Level Error -Message "Failed to broadcast to group '$GroupName': $_" -Exception $_.Exception
 67        }
 68    }
 69}

Methods/Properties

Send-KrSignalRGroupMessage()