Skip to content

Commit c54b4d6

Browse files
author
James Brundage
committed
feat: Get-WebSocket -Force ( Fixes #58 )
1 parent a88cb3b commit c54b4d6

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

Commands/Get-WebSocket.ps1

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,10 @@ function Get-WebSocket {
193193
[switch]
194194
$Binary,
195195

196+
# If set, will force a new job to be created, rather than reusing an existing job.
197+
[switch]
198+
$Force,
199+
196200
# The subprotocol used by the websocket. If not provided, this will default to `json`.
197201
[string]
198202
$SubProtocol,
@@ -437,6 +441,8 @@ function Get-WebSocket {
437441
$ExecutionContext.SessionState.PSVariable.Set($keyValue.Key, $keyValue.Value)
438442
}
439443

444+
$Variable.JobRunspace = [Runspace]::DefaultRunspace
445+
440446
# If we have routes, we will cache all of their possible parameters now
441447
if ($route.Count) {
442448
# We want to keep the parameter sets
@@ -782,7 +788,7 @@ function Get-WebSocket {
782788
}
783789
}
784790

785-
if ($existingJob) {
791+
if ($existingJob -and -not $Force) {
786792
$existingJob
787793
} else {
788794
Start-ThreadJob -ScriptBlock $SocketClientJob -Name $Name -InitializationScript $InitializationScript -ArgumentList $Variable

0 commit comments

Comments
 (0)