@@ -12,6 +12,14 @@ It has a single command: Get-WebSocket.
12
12
13
13
Because ` Get ` is the default verb in PowerShell, you can just call it ` WebSocket ` .
14
14
15
+ ## WebSocket Container
16
+
17
+ You can use the WebSocket module within a container:
18
+
19
+ ~~~ powershell
20
+ docker pull ghcr.io/powershellweb/websocket
21
+ docker run -it ghcr.io/powershellweb/websocket
22
+ ~~~
15
23
16
24
### Installing and Importing
17
25
@@ -30,4 +38,61 @@ To connect to a websocket and start listening for results, use [Get-WebSocket](G
30
38
websocket wss://jetstream2.us-east.bsky.network/subscribe?wantedCollections=app.bsky.feed.post -Watch
31
39
~~~
32
40
33
- To stop watching a websocket, simply stop the background job.
41
+ To stop watching a websocket, simply stop the background job.
42
+
43
+ ### More Examples
44
+
45
+ #### Get-WebSocket Example 1
46
+
47
+ ~~~ powershell
48
+ # Create a WebSocket job that connects to a WebSocket and outputs the results.
49
+ Get-WebSocket -WebSocketUri "wss://localhost:9669"
50
+ ~~~
51
+ #### Get-WebSocket Example 2
52
+
53
+ ~~~ powershell
54
+ # 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
56
+ ~~~
57
+ #### Get-WebSocket Example 3
58
+
59
+ ~~~ powershell
60
+ websocket jetstream2.us-east.bsky.network/subscribe?wantedCollections=app.bsky.feed.post -Tail |
61
+ Foreach-Object {
62
+ $in = $_
63
+ if ($in.commit.record.text -match '[\p{IsHighSurrogates}\p{IsLowSurrogates}]+') {
64
+ Write-Host $matches.0 -NoNewline
65
+ }
66
+ }
67
+ ~~~
68
+ #### Get-WebSocket Example 4
69
+
70
+ ~~~ powershell
71
+ $emojiPattern = '[\p{IsHighSurrogates}\p{IsLowSurrogates}\p{IsVariationSelectors}\p{IsCombiningHalfMarks}]+)'
72
+ websocket jetstream2.us-east.bsky.network/subscribe?wantedCollections=app.bsky.feed.post -Tail |
73
+ Foreach-Object {
74
+ $in = $_
75
+ $spacing = (' ' * (Get-Random -Minimum 0 -Maximum 7))
76
+ if ($in.commit.record.text -match "(?>(?:$emojiPattern|\#\w+)") {
77
+ $match = $matches.0
78
+ Write-Host $spacing,$match,$spacing -NoNewline
79
+ }
80
+ }
81
+ ~~~
82
+ #### Get-WebSocket Example 5
83
+
84
+ ~~~ powershell
85
+ websocket wss://jetstream2.us-east.bsky.network/subscribe?wantedCollections=app.bsky.feed.post -Watch |
86
+ Where-Object {
87
+ $_.commit.record.embed.'$type' -eq 'app.bsky.embed.external'
88
+ } |
89
+ Foreach-Object {
90
+ $_.commit.record.embed.external.uri
91
+ }
92
+ ~~~
93
+ #### Get-WebSocket Example 6
94
+
95
+ ~~~ powershell
96
+
97
+ ~~~
98
+
0 commit comments