@@ -184,7 +184,9 @@ function Get-WebSocket {
184
184
185
185
# A collection of query parameters.
186
186
# These will be appended onto the `-SocketUrl`.
187
+ # Multiple values for a single parameter will be passed as multiple parameters.
187
188
[Parameter (ValueFromPipelineByPropertyName , ParameterSetName = ' WebSocketClient' )]
189
+ [Alias (' QueryParameters' , ' Query' )]
188
190
[Collections.IDictionary ]
189
191
$QueryParameter ,
190
192
@@ -315,7 +317,7 @@ function Get-WebSocket {
315
317
$values = $_.values
316
318
foreach ($key in $keys ) {
317
319
if ($key -isnot [scriptblock ]) {
318
- throw " Keys '$key ' must be a scriptblock"
320
+ throw " Key '$key ' must be a scriptblock"
319
321
}
320
322
}
321
323
foreach ($value in $values ) {
@@ -329,7 +331,10 @@ function Get-WebSocket {
329
331
[Collections.IDictionary ]
330
332
$WatchFor ,
331
333
332
- # The timeout for the WebSocket connection. If this is provided, after the timeout elapsed, the WebSocket will be closed.
334
+ # The timeout for the WebSocket connection.
335
+ # If this is provided, after the timeout elapsed, the WebSocket will be closed.
336
+ [Parameter (ValueFromPipelineByPropertyName )]
337
+ [Alias (' Lifespan' )]
333
338
[TimeSpan ]
334
339
$TimeOut ,
335
340
@@ -810,12 +815,20 @@ function Get-WebSocket {
810
815
" <style type='text/css'>$css </style>"
811
816
}
812
817
}
813
- )
818
+ )
814
819
815
820
$httpListener.psobject.properties.add ([psnoteproperty ]::new(' JobVariable' , $Variable ), $true )
821
+ $listenerStartTime = [DateTime ]::Now
816
822
817
823
# While the listener is listening,
818
824
while ($httpListener.IsListening ) {
825
+ # If we've given a timeout for the listener,
826
+ # and the listener has been open for longer than the timeout,
827
+ if ($Timeout -and ([DateTime ]::Now - $listenerStartTime ) -gt $TimeOut ) {
828
+ # then it's closing time (you don't have to go home but you can't stay here).
829
+ $httpListener.Stop ()
830
+ break
831
+ }
819
832
# get the context asynchronously.
820
833
$contextAsync = $httpListener.GetContextAsync ()
821
834
# and wait for it to complete.
0 commit comments