Skip to content

Commit 8f767b3

Browse files
author
James Brundage
committed
feat: Get-WebSocket honoring CloseStatusDescription ( Fixes #80 )
1 parent 2beade2 commit 8f767b3

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

Commands/Get-WebSocket.ps1

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,11 @@ function Get-WebSocket {
255255
[Parameter(ParameterSetName='WebSocketClient')]
256256
[Alias('Authorize','HelloMessage')]
257257
[PSObject]
258-
$Authenticate,
258+
$Authenticate,
259+
260+
[Alias('Identify','AutoReply')]
261+
[PSObject]
262+
$Reply,
259263

260264
# If set, will watch the output of the WebSocket job, outputting results continuously instead of outputting a websocket job.
261265
[Parameter(ParameterSetName='WebSocketClient')]
@@ -428,7 +432,12 @@ function Get-WebSocket {
428432
$saidHello = $null
429433

430434
:WebSocketMessageLoop while ($true) {
431-
if ($ws.State -ne 'Open') {break }
435+
if ($ws.State -ne 'Open') {
436+
if ($ws.CloseStatusDescription) {
437+
Write-Error $ws.CloseStatusDescription -TargetObject $ws
438+
}
439+
break
440+
}
432441
if ($TimeOut -and ([DateTime]::Now - $webSocketStartTime) -gt $TimeOut) {
433442
$ws.CloseAsync([Net.WebSockets.WebSocketCloseStatus]::NormalClosure, 'Timeout', $CT).Wait()
434443
break

0 commit comments

Comments
 (0)