@@ -3,14 +3,35 @@ function Get-WebSocket {
3
3
. SYNOPSIS
4
4
WebSockets in PowerShell.
5
5
. DESCRIPTION
6
- Get-WebSocket allows you to connect to a websocket and handle the output.
6
+ Get-WebSocket gets a websocket.
7
+
8
+ This will create a job that connects to a WebSocket and outputs the results.
9
+
10
+ If the `-Watch` parameter is provided, will output a continous stream of objects from the websocket.
7
11
. EXAMPLE
8
12
# Create a WebSocket job that connects to a WebSocket and outputs the results.
9
- Get-WebSocket -WebSocketUri "wss://localhost:9669"
13
+ Get-WebSocket -WebSocketUri "wss://localhost:9669/ "
10
14
. EXAMPLE
11
15
# Get is the default verb, so we can just say WebSocket.
16
+ # `-Watch` will output a continous stream of objects from the websocket.
17
+ # For example, let's Watch BlueSky, but just the text.
18
+ websocket wss://jetstream2.us-west.bsky.network/subscribe?wantedCollections=app.bsky.feed.post -Watch |
19
+ % {
20
+ $_.commit.record.text
21
+ }
22
+ . EXAMPLE
23
+ # Watch BlueSky, but just the text and spacing
24
+ $blueSkySocketUrl = "wss://jetstream2.us-$(
25
+ 'east','west'|Get-Random
26
+ ).bsky.network/subscribe?$(@(
27
+ "wantedCollections=app.bsky.feed.post"
28
+ ) -join '&')"
29
+ websocket $blueSkySocketUrl -Watch |
30
+ % { Write-Host "$(' ' * (Get-Random -Max 10))$($_.commit.record.text)$($(' ' * (Get-Random -Max 10)))"}
31
+ . EXAMPLE
12
32
websocket wss://jetstream2.us-east.bsky.network/subscribe?wantedCollections=app.bsky.feed.post
13
33
. EXAMPLE
34
+ # Watch BlueSky, but just the emoji
14
35
websocket jetstream2.us-east.bsky.network/subscribe?wantedCollections=app.bsky.feed.post -Tail |
15
36
Foreach-Object {
16
37
$in = $_
@@ -20,7 +41,7 @@ function Get-WebSocket {
20
41
}
21
42
. EXAMPLE
22
43
$emojiPattern = '[\p{IsHighSurrogates}\p{IsLowSurrogates}\p{IsVariationSelectors}\p{IsCombiningHalfMarks}]+)'
23
- websocket jetstream2.us-east .bsky.network/subscribe?wantedCollections=app.bsky.feed.post -Tail |
44
+ websocket wss:// jetstream2.us-west .bsky.network/subscribe?wantedCollections=app.bsky.feed.post -Tail |
24
45
Foreach-Object {
25
46
$in = $_
26
47
$spacing = (' ' * (Get-Random -Minimum 0 -Maximum 7))
@@ -37,8 +58,6 @@ function Get-WebSocket {
37
58
Foreach-Object {
38
59
$_.commit.record.embed.external.uri
39
60
}
40
- . EXAMPLE
41
-
42
61
#>
43
62
[CmdletBinding (PositionalBinding = $false )]
44
63
param (
0 commit comments