Skip to content

Commit e9d5817

Browse files
author
James Brundage
committed
docs: More Get-WebSocket examples ( Fixes #27 )
1 parent c49d8e8 commit e9d5817

File tree

2 files changed

+25
-6
lines changed

2 files changed

+25
-6
lines changed

Commands/Get-WebSocket.ps1

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,35 @@ function Get-WebSocket {
33
.SYNOPSIS
44
WebSockets in PowerShell.
55
.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.
711
.EXAMPLE
812
# 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/"
1014
.EXAMPLE
1115
# 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
1232
websocket wss://jetstream2.us-east.bsky.network/subscribe?wantedCollections=app.bsky.feed.post
1333
.EXAMPLE
34+
# Watch BlueSky, but just the emoji
1435
websocket jetstream2.us-east.bsky.network/subscribe?wantedCollections=app.bsky.feed.post -Tail |
1536
Foreach-Object {
1637
$in = $_
@@ -20,7 +41,7 @@ function Get-WebSocket {
2041
}
2142
.EXAMPLE
2243
$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 |
2445
Foreach-Object {
2546
$in = $_
2647
$spacing = (' ' * (Get-Random -Minimum 0 -Maximum 7))
@@ -37,8 +58,6 @@ function Get-WebSocket {
3758
Foreach-Object {
3859
$_.commit.record.embed.external.uri
3960
}
40-
.EXAMPLE
41-
4261
#>
4362
[CmdletBinding(PositionalBinding=$false)]
4463
param(

README.ps.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
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

0 commit comments

Comments
 (0)