@@ -16,12 +16,13 @@ function Get-WebSocket {
1616        https://learn.microsoft.com/en-us/dotnet/api/system.net.httplistener?wt.mc_id=MVP_321542 
1717    . EXAMPLE  
1818        # Create a WebSocket job that connects to a WebSocket and outputs the results. 
19-         Get-WebSocket -SocketUrl "wss://localhost:9669/"  
19+         $socketServer = Get-WebSocket -RootUrl "http://localhost:8387/" -HTML "<h1>WebSocket Server</h1>" 
20+         $socketClient = Get-WebSocket -SocketUrl "ws://localhost:8387/" 
2021    . EXAMPLE  
2122        # Get is the default verb, so we can just say WebSocket. 
2223        # `-Watch` will output a continous stream of objects from the websocket. 
23-         # For example, let's Watch BlueSky, but just the text.          
24-         websocket wss://jetstream2.us-west.bsky.network/subscribe?wantedCollections=app.bsky.feed.post -Watch | 
24+         # For example, let's Watch BlueSky, but just the text  
25+         websocket wss://jetstream2.us-west.bsky.network/subscribe?wantedCollections=app.bsky.feed.post -Watch -Maximum 1kb  | 
2526            % {  
2627                $_.commit.record.text 
2728            } 
@@ -33,14 +34,19 @@ function Get-WebSocket {
3334            "wantedCollections=app.bsky.feed.post" 
3435        ) -join '&')" 
3536        websocket $blueSkySocketUrl -Watch |  
36-             % { Write-Host "$(' ' * (Get-Random -Max 10))$($_.commit.record.text)$($(' ' * (Get-Random -Max 10)))"} 
37-     . EXAMPLE          
37+             % { Write-Host "$(' ' * (Get-Random -Max 10))$($_.commit.record.text)$($(' ' * (Get-Random -Max 10)))"} -Max 1kb 
38+     . EXAMPLE  
39+         # Watch continuously in a background job. 
3840        websocket wss://jetstream2.us-east.bsky.network/subscribe?wantedCollections=app.bsky.feed.post 
3941    . EXAMPLE  
40-         websocket wss://jetstream2.us-west.bsky.network/subscribe -QueryParameter @{ wantedCollections = 'app.bsky.feed.post' } -Max 1 -Debug 
42+         # Watch the first message in -Debug mode.   
43+         # This allows you to literally debug the WebSocket messages as they are encountered. 
44+         websocket wss://jetstream2.us-west.bsky.network/subscribe -QueryParameter @{ 
45+             wantedCollections = 'app.bsky.feed.post' 
46+         } -Max 1 -Debug 
4147    . EXAMPLE  
4248        # Watch BlueSky, but just the emoji 
43-         websocket jetstream2.us-east.bsky.network/subscribe?wantedCollections=app.bsky.feed.post -Tail | 
49+         websocket jetstream2.us-east.bsky.network/subscribe?wantedCollections=app.bsky.feed.post -Tail -Max 1kb  | 
4450            Foreach-Object { 
4551                $in = $_ 
4652                if ($in.commit.record.text -match '[\p{IsHighSurrogates}\p{IsLowSurrogates}]+') { 
@@ -113,7 +119,6 @@ function Get-WebSocket {
113119            Group | 
114120            Sort Count -Descending | 
115121            Select -First 10 
116-      
117122    #>  
118123    [CmdletBinding (
119124        PositionalBinding = $false , 
@@ -1231,7 +1236,9 @@ function Get-WebSocket {
12311236                    $httpListenerJob  =  $existingJob 
12321237                    $httpListener  =  $existingJob.HttpListener  
12331238                } else  {
1234-                     $httpListenerJob  =  Start-ThreadJob  - ScriptBlock $SocketServerJob  - Name " $RootUrl " - ArgumentList $Variable  @StartThreadJobSplat 
1239+                     $httpListenerJob  =  Start-ThreadJob  - ScriptBlock $SocketServerJob  - Name " $RootUrl " - ArgumentList $Variable  @StartThreadJobSplat                     
1240+                     $httpListenerJob.pstypenames.insert  (0 ,  ' WebSocket.ThreadJob' 
1241+                     $httpListenerJob.pstypenames.insert  (0 ,  ' WebSocket.Server.ThreadJob' 
12351242                }
12361243            }
12371244
@@ -1322,6 +1329,7 @@ function Get-WebSocket {
13221329                )
13231330            }
13241331            $webSocketJob.pstypenames.insert  (0 ,  ' WebSocket.ThreadJob' 
1332+             $webSocketJob.pstypenames.insert  (0 ,  ' WebSocket.Client.ThreadJob' 
13251333        }
13261334
13271335        #  If we're broadcasting a message
0 commit comments