11<div align =' center ' >
2- <img alt='WebSocket Logo (Animated)' style='height:50 %' src='Assets/WebSocket-Animated.svg' />
2+ <img alt='WebSocket Logo (Animated)' style='width:33 %' src='Assets/WebSocket-Animated.svg' />
33</div >
44
55# WebSocket
@@ -46,17 +46,40 @@ 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 -WebSocketUri "wss://localhost:9669"
49+ Get-WebSocket -WebSocketUri "wss://localhost:9669/ "
5050~~~
5151 #### Get-WebSocket Example 2
5252
5353~~~ powershell
5454# Get is the default verb, so we can just say WebSocket.
55- websocket wss://jetstream2.us-east.bsky.network/subscribe?wantedCollections=app.bsky.feed.post
55+ # `-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 |
58+ % {
59+ $_.commit.record.text
60+ }
5661~~~
5762 #### Get-WebSocket Example 3
5863
5964~~~ powershell
65+ # Watch BlueSky, but just the text and spacing
66+ $blueSkySocketUrl = "wss://jetstream2.us-$(
67+ 'east','west'|Get-Random
68+ ).bsky.network/subscribe?$(@(
69+ "wantedCollections=app.bsky.feed.post"
70+ ) -join '&')"
71+ websocket $blueSkySocketUrl -Watch |
72+ % { Write-Host "$(' ' * (Get-Random -Max 10))$($_.commit.record.text)$($(' ' * (Get-Random -Max 10)))"}
73+ ~~~
74+ #### Get-WebSocket Example 4
75+
76+ ~~~ powershell
77+ websocket wss://jetstream2.us-east.bsky.network/subscribe?wantedCollections=app.bsky.feed.post
78+ ~~~
79+ #### Get-WebSocket Example 5
80+
81+ ~~~ powershell
82+ # Watch BlueSky, but just the emoji
6083websocket jetstream2.us-east.bsky.network/subscribe?wantedCollections=app.bsky.feed.post -Tail |
6184 Foreach-Object {
6285 $in = $_
@@ -65,11 +88,11 @@ websocket jetstream2.us-east.bsky.network/subscribe?wantedCollections=app.bsky.f
6588 }
6689 }
6790~~~
68- #### Get-WebSocket Example 4
91+ #### Get-WebSocket Example 6
6992
7093~~~ powershell
7194$emojiPattern = '[\p{IsHighSurrogates}\p{IsLowSurrogates}\p{IsVariationSelectors}\p{IsCombiningHalfMarks}]+)'
72- websocket jetstream2.us-east .bsky.network/subscribe?wantedCollections=app.bsky.feed.post -Tail |
95+ websocket wss:// jetstream2.us-west .bsky.network/subscribe?wantedCollections=app.bsky.feed.post -Tail |
7396 Foreach-Object {
7497 $in = $_
7598 $spacing = (' ' * (Get-Random -Minimum 0 -Maximum 7))
@@ -79,7 +102,7 @@ websocket jetstream2.us-east.bsky.network/subscribe?wantedCollections=app.bsky.f
79102 }
80103 }
81104~~~
82- #### Get-WebSocket Example 5
105+ #### Get-WebSocket Example 7
83106
84107~~~ powershell
85108websocket wss://jetstream2.us-east.bsky.network/subscribe?wantedCollections=app.bsky.feed.post -Watch |
@@ -90,8 +113,3 @@ websocket wss://jetstream2.us-east.bsky.network/subscribe?wantedCollections=app.
90113 $_.commit.record.embed.external.uri
91114 }
92115~~~
93- #### Get-WebSocket Example 6
94-
95- ~~~ powershell
96-
97- ~~~
0 commit comments