@@ -46,15 +46,16 @@ To stop watching a websocket, simply stop the background job.
4646
4747~~~ powershell
4848# Create a WebSocket job that connects to a WebSocket and outputs the results.
49- Get-WebSocket -SocketUrl "wss://localhost:9669/"
49+ $socketServer = Get-WebSocket -RootUrl "http://localhost:8387/" -HTML "<h1>WebSocket Server</h1>"
50+ $socketClient = Get-WebSocket -SocketUrl "ws://localhost:8387/"
5051~~~
5152 #### Get-WebSocket Example 2
5253
5354~~~ powershell
5455# Get is the default verb, so we can just say WebSocket.
5556# `-Watch` will output a continous stream of objects from the websocket.
56- # For example, let's Watch BlueSky, but just the text.
57- websocket wss://jetstream2.us-west.bsky.network/subscribe?wantedCollections=app.bsky.feed.post -Watch |
57+ # For example, let's Watch BlueSky, but just the text
58+ websocket wss://jetstream2.us-west.bsky.network/subscribe?wantedCollections=app.bsky.feed.post -Watch -Maximum 1kb |
5859 % {
5960 $_.commit.record.text
6061 }
@@ -69,23 +70,28 @@ $blueSkySocketUrl = "wss://jetstream2.us-$(
6970 "wantedCollections=app.bsky.feed.post"
7071) -join '&')"
7172websocket $blueSkySocketUrl -Watch |
72- % { Write-Host "$(' ' * (Get-Random -Max 10))$($_.commit.record.text)$($(' ' * (Get-Random -Max 10)))"}
73+ % { Write-Host "$(' ' * (Get-Random -Max 10))$($_.commit.record.text)$($(' ' * (Get-Random -Max 10)))"} -Max 1kb
7374~~~
7475 #### Get-WebSocket Example 4
7576
7677~~~ powershell
78+ # Watch continuously in a background job.
7779websocket wss://jetstream2.us-east.bsky.network/subscribe?wantedCollections=app.bsky.feed.post
7880~~~
7981 #### Get-WebSocket Example 5
8082
8183~~~ powershell
82- websocket wss://jetstream2.us-west.bsky.network/subscribe -QueryParameter @{ wantedCollections = 'app.bsky.feed.post' } -Max 1 -Debug
84+ # Watch the first message in -Debug mode.
85+ # This allows you to literally debug the WebSocket messages as they are encountered.
86+ websocket wss://jetstream2.us-west.bsky.network/subscribe -QueryParameter @{
87+ wantedCollections = 'app.bsky.feed.post'
88+ } -Max 1 -Debug
8389~~~
8490 #### Get-WebSocket Example 6
8591
8692~~~ powershell
8793# Watch BlueSky, but just the emoji
88- websocket jetstream2.us-east.bsky.network/subscribe?wantedCollections=app.bsky.feed.post -Tail |
94+ websocket jetstream2.us-east.bsky.network/subscribe?wantedCollections=app.bsky.feed.post -Tail -Max 1kb |
8995 Foreach-Object {
9096 $in = $_
9197 if ($in.commit.record.text -match '[\p{IsHighSurrogates}\p{IsLowSurrogates}]+') {
0 commit comments