Skip to content

Commit acda54f

Browse files
committed
Fix WebSocket server to use Text frame type for text messages
Changed the frame type from 'Binary' to 'Text' when sending text/JSON messages from the server. This ensures compliance with the WebSocket protocol specification and prevents clients from misinterpreting text data as binary.
1 parent 5bf7dc5 commit acda54f

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

  • Types/WebSocket.ThreadJob/WebSocket.Server.ThreadJob

Types/WebSocket.ThreadJob/WebSocket.Server.ThreadJob/Send.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ function sendMessage {
2828
$messageSegment = [ArraySegment[byte]]::new($OutputEncoding.GetBytes($jsonMessage))
2929
foreach ($socket in $sockets) {
3030
if ($null -ne $messageSegment -and $socket.SendAsync) {
31-
$null = $socket.SendAsync($messageSegment, 'Binary', 'EndOfMessage',[Threading.Cancellationtoken]::None)
31+
$null = $socket.SendAsync($messageSegment, 'Text', 'EndOfMessage',[Threading.Cancellationtoken]::None)
3232
}
3333
}
3434
}

0 commit comments

Comments
 (0)