Skip to content

Commit df6708a

Browse files
author
James Brundage
committed
feat: Get-WebSocket improving piping ( Fixes #87 )
1 parent 9867f07 commit df6708a

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

Commands/Get-WebSocket.ps1

+19-2
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ function Get-WebSocket {
213213
[Alias('Headers')]
214214
$Header,
215215

216-
# The name of the WebSocket job.
216+
# The name of the WebSocket job.
217217
[string]
218218
$Name,
219219

@@ -222,6 +222,7 @@ function Get-WebSocket {
222222
$InitializationScript = {},
223223

224224
# The buffer size. Defaults to 16kb.
225+
[Parameter(ValueFromPipelineByPropertyName)]
225226
[int]
226227
$BufferSize = 64kb,
227228

@@ -346,10 +347,12 @@ function Get-WebSocket {
346347
$PSTypeName,
347348

348349
# The maximum number of messages to receive before closing the WebSocket.
350+
[Parameter(ValueFromPipelineByPropertyName)]
349351
[long]
350352
$Maximum,
351353

352354
# The throttle limit used when creating background jobs.
355+
[Parameter(ValueFromPipelineByPropertyName)]
353356
[int]
354357
$ThrottleLimit = 64,
355358

@@ -1138,7 +1141,21 @@ function Get-WebSocket {
11381141
}
11391142
}
11401143

1141-
process {
1144+
process {
1145+
# Sometimes we want to customize the behavior of a command based off of the input object
1146+
# So, start off by capturing $_
1147+
$inputObject = $_
1148+
# If the input was a job, we might remap a parameter
1149+
if ($inputObject -is [ThreadJob.ThreadJob]) {
1150+
if ($inputObject.WebSocket -is [Net.WebSockets.ClientWebSocket] -and
1151+
$inputObject.SocketUrl) {
1152+
$SocketUrl = $inputObject.SocketUrl
1153+
}
1154+
if ($inputObject.HttpListener -is [Net.HttpListener] -and
1155+
$inputObject.RootUrl) {
1156+
$RootUrl = $inputObject.RootUrl
1157+
}
1158+
}
11421159
if ((-not $SocketUrl) -and (-not $RootUrl)) {
11431160
$socketAndListenerJobs =
11441161
foreach ($job in Get-Job) {

0 commit comments

Comments
 (0)