Skip to content

Commit 22aaf89

Browse files
author
James Brundage
committed
docs: Get-WebSocket examples
1 parent 3ffca35 commit 22aaf89

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

Commands/Get-WebSocket.ps1

+3-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ function Get-WebSocket {
1818
# Create a WebSocket job that connects to a WebSocket and outputs the results.
1919
$socketServer = Get-WebSocket -RootUrl "http://localhost:8387/" -HTML "<h1>WebSocket Server</h1>"
2020
$socketClient = Get-WebSocket -SocketUrl "ws://localhost:8387/"
21+
foreach ($n in 1..10) { $socketServer.Send(@{n=Get-Random}) }
22+
$socketClient | Receive-Job -Keep
2123
.EXAMPLE
2224
# Get is the default verb, so we can just say WebSocket.
2325
# `-Watch` will output a continous stream of objects from the websocket.
@@ -918,7 +920,7 @@ function Get-WebSocket {
918920
# If the request is a websocket request
919921
if ($Request.IsWebSocketRequest) {
920922
# we will change the event identifier to a websocket scheme.
921-
$eventIdentifier = $eventIdentifier -replace '^http', 'ws'
923+
$eventIdentifier = $eventIdentifier -replace '^http', 'ws'
922924
# and call the `AcceptWebSocketAsync` method to upgrade the connection.
923925
$acceptWebSocket = $context.AcceptWebSocketAsync('json')
924926
# Once again, we'll use a tight loop to wait for the upgrade to complete or fail.

0 commit comments

Comments
 (0)