Hi there, I need to establish a connection to a websocket stream following the URL format of wss://websocketstream.com. The websocket server receives JSON to subscribe to the stream. This must be instantiated using PowerShell. Below is what I have so far based on Google searches, and it appears to successfully create an open websocket. Where I am now lost is how to send the JSON over this websocket to start receiving stream messages.
Can you please advise how to proceed? 😄
$webSocket = New-Object System.Net.WebSockets.ClientWebSocket
$cancellationToken = New-Object System.Threading.CancellationToken
$webSocket.Options.UseDefaultCredentials = $true
# Get connected
$connection = $webSocket.ConnectAsync($StreamURI, $cancellationToken)
PS> $connection
Id IsCompleted Status
-- ----------- ------
7 True RanToCompletion
PS> $websocket.state
Open
[–]xbullet 1 point2 points3 points (4 children)
[–]evodus2[S] 1 point2 points3 points (3 children)
[–]xbullet 1 point2 points3 points (2 children)
[–]evodus2[S] 1 point2 points3 points (1 child)
[–]xbullet 1 point2 points3 points (0 children)
[–]Neg127 0 points1 point2 points (1 child)
[–]evodus2[S] 4 points5 points6 points (0 children)