|
37 | 37 | {
|
38 | 38 | "Title": "EXAMPLE 1",
|
39 | 39 | "Markdown": "Create a WebSocket job that connects to a WebSocket and outputs the results.",
|
40 |
| - "Code": "Get-WebSocket -SocketUrl \"wss://localhost:9669/\"" |
| 40 | + "Code": "$socketServer = Get-WebSocket -RootUrl \"http://localhost:8387/\" -HTML \"<h1>WebSocket Server</h1>\"\n$socketClient = Get-WebSocket -SocketUrl \"ws://localhost:8387/\"" |
41 | 41 | },
|
42 | 42 | {
|
43 | 43 | "Title": "EXAMPLE 2",
|
44 |
| - "Markdown": "Get is the default verb, so we can just say WebSocket.\n`-Watch` will output a continous stream of objects from the websocket.\nFor example, let's Watch BlueSky, but just the text. ", |
45 |
| - "Code": "websocket wss://jetstream2.us-west.bsky.network/subscribe?wantedCollections=app.bsky.feed.post -Watch |\n % { \n $_.commit.record.text\n }" |
| 44 | + "Markdown": "Get is the default verb, so we can just say WebSocket.\n`-Watch` will output a continous stream of objects from the websocket.\nFor example, let's Watch BlueSky, but just the text ", |
| 45 | + "Code": "websocket wss://jetstream2.us-west.bsky.network/subscribe?wantedCollections=app.bsky.feed.post -Watch -Maximum 1kb |\n % { \n $_.commit.record.text\n }" |
46 | 46 | },
|
47 | 47 | {
|
48 | 48 | "Title": "EXAMPLE 3",
|
49 | 49 | "Markdown": "Watch BlueSky, but just the text and spacing",
|
50 |
| - "Code": "$blueSkySocketUrl = \"wss://jetstream2.us-$(\n 'east','west'|Get-Random\n).bsky.network/subscribe?$(@(\n \"wantedCollections=app.bsky.feed.post\"\n) -join '&')\"\nwebsocket $blueSkySocketUrl -Watch | \n % { Write-Host \"$(' ' * (Get-Random -Max 10))$($_.commit.record.text)$($(' ' * (Get-Random -Max 10)))\"}" |
| 50 | + "Code": "$blueSkySocketUrl = \"wss://jetstream2.us-$(\n 'east','west'|Get-Random\n).bsky.network/subscribe?$(@(\n \"wantedCollections=app.bsky.feed.post\"\n) -join '&')\"\nwebsocket $blueSkySocketUrl -Watch | \n % { Write-Host \"$(' ' * (Get-Random -Max 10))$($_.commit.record.text)$($(' ' * (Get-Random -Max 10)))\"} -Max 1kb" |
51 | 51 | },
|
52 | 52 | {
|
53 | 53 | "Title": "EXAMPLE 4",
|
54 |
| - "Markdown": "", |
| 54 | + "Markdown": "Watch continuously in a background job.", |
55 | 55 | "Code": "websocket wss://jetstream2.us-east.bsky.network/subscribe?wantedCollections=app.bsky.feed.post"
|
56 | 56 | },
|
57 | 57 | {
|
58 | 58 | "Title": "EXAMPLE 5",
|
59 |
| - "Markdown": "", |
60 |
| - "Code": "websocket wss://jetstream2.us-west.bsky.network/subscribe -QueryParameter @{ wantedCollections = 'app.bsky.feed.post' } -Max 1 -Debug" |
| 59 | + "Markdown": "Watch the first message in -Debug mode. \nThis allows you to literally debug the WebSocket messages as they are encountered.", |
| 60 | + "Code": "websocket wss://jetstream2.us-west.bsky.network/subscribe -QueryParameter @{\n wantedCollections = 'app.bsky.feed.post'\n} -Max 1 -Debug" |
61 | 61 | },
|
62 | 62 | {
|
63 | 63 | "Title": "EXAMPLE 6",
|
64 | 64 | "Markdown": "Watch BlueSky, but just the emoji",
|
65 |
| - "Code": "websocket jetstream2.us-east.bsky.network/subscribe?wantedCollections=app.bsky.feed.post -Tail |\n Foreach-Object {\n $in = $_\n if ($in.commit.record.text -match '[\\p{IsHighSurrogates}\\p{IsLowSurrogates}]+') {\n Write-Host $matches.0 -NoNewline\n }\n }" |
| 65 | + "Code": "websocket jetstream2.us-east.bsky.network/subscribe?wantedCollections=app.bsky.feed.post -Tail -Max 1kb |\n Foreach-Object {\n $in = $_\n if ($in.commit.record.text -match '[\\p{IsHighSurrogates}\\p{IsLowSurrogates}]+') {\n Write-Host $matches.0 -NoNewline\n }\n }" |
66 | 66 | },
|
67 | 67 | {
|
68 | 68 | "Title": "EXAMPLE 7",
|
|
0 commit comments