@@ -8,22 +8,47 @@ WebSockets in PowerShell.
88
99### Description
1010
11- Get-WebSocket allows you to connect to a websocket and handle the output.
11+ Get-WebSocket gets a websocket.
12+
13+ This will create a job that connects to a WebSocket and outputs the results.
14+
15+ If the ` -Watch ` parameter is provided, will output a continous stream of objects from the websocket.
1216
1317---
1418
1519### Examples
1620Create a WebSocket job that connects to a WebSocket and outputs the results.
1721
1822``` PowerShell
19- Get-WebSocket -WebSocketUri "wss://localhost:9669"
23+ Get-WebSocket -WebSocketUri "wss://localhost:9669/ "
2024```
2125Get is the default verb, so we can just say WebSocket.
26+ ` -Watch ` will output a continous stream of objects from the websocket.
27+ For example, let's Watch BlueSky, but just the text.
28+
29+ ``` PowerShell
30+ websocket wss://jetstream2.us-west.bsky.network/subscribe?wantedCollections=app.bsky.feed.post -Watch |
31+ % {
32+ $_.commit.record.text
33+ }
34+ ```
35+ Watch BlueSky, but just the text and spacing
36+
37+ ``` PowerShell
38+ $blueSkySocketUrl = "wss://jetstream2.us-$(
39+ 'east','west'|Get-Random
40+ ).bsky.network/subscribe?$(@(
41+ "wantedCollections=app.bsky.feed.post"
42+ ) -join '&')"
43+ websocket $blueSkySocketUrl -Watch |
44+ % { Write-Host "$(' ' * (Get-Random -Max 10))$($_.commit.record.text)$($(' ' * (Get-Random -Max 10)))"}
45+ ```
46+ > EXAMPLE 4
2247
2348``` PowerShell
2449websocket wss://jetstream2.us-east.bsky.network/subscribe?wantedCollections=app.bsky.feed.post
2550```
26- > EXAMPLE 3
51+ Watch BlueSky, but just the emoji
2752
2853``` PowerShell
2954websocket jetstream2.us-east.bsky.network/subscribe?wantedCollections=app.bsky.feed.post -Tail |
@@ -34,11 +59,11 @@ websocket jetstream2.us-east.bsky.network/subscribe?wantedCollections=app.bsky.f
3459 }
3560 }
3661```
37- > EXAMPLE 4
62+ > EXAMPLE 6
3863
3964``` PowerShell
4065$emojiPattern = '[\p{IsHighSurrogates}\p{IsLowSurrogates}\p{IsVariationSelectors}\p{IsCombiningHalfMarks}]+)'
41- websocket jetstream2.us-east .bsky.network/subscribe?wantedCollections=app.bsky.feed.post -Tail |
66+ websocket wss:// jetstream2.us-west .bsky.network/subscribe?wantedCollections=app.bsky.feed.post -Tail |
4267 Foreach-Object {
4368 $in = $_
4469 $spacing = (' ' * (Get-Random -Minimum 0 -Maximum 7))
@@ -48,7 +73,7 @@ websocket jetstream2.us-east.bsky.network/subscribe?wantedCollections=app.bsky.f
4873 }
4974 }
5075```
51- > EXAMPLE 5
76+ > EXAMPLE 7
5277
5378``` PowerShell
5479websocket wss://jetstream2.us-east.bsky.network/subscribe?wantedCollections=app.bsky.feed.post -Watch |
@@ -59,7 +84,6 @@ websocket wss://jetstream2.us-east.bsky.network/subscribe?wantedCollections=app.
5984 $_.commit.record.embed.external.uri
6085 }
6186```
62- > EXAMPLE 6
6387
6488---
6589
0 commit comments