Skip to content

Commit de28ff9

Browse files
committed
fix: Only send one JSON array per websocket packet
While the C# client can parse multiple JSON bodies in a string, JS can't, and gets tripped on this. Fixes #645
1 parent fccf1d6 commit de28ff9

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

Buttplug.Server.Connectors.WebsocketServer/ButtplugWebsocketServerSession.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,12 @@ public async Task RunServerSession()
117117
try
118118
{
119119
_outgoingMessages.TryReceiveAll(out var msgs);
120-
var outMsgs = msgs.Aggregate(string.Empty, (current, msg) => current + msg);
121120
if (_ws != null && _ws.IsConnected)
122121
{
123-
await _ws.WriteStringAsync(outMsgs, _linkedCancelSource.Token).ConfigureAwait(false);
122+
foreach (var msg in msgs)
123+
{
124+
await _ws.WriteStringAsync(msg, _linkedCancelSource.Token).ConfigureAwait(false);
125+
}
124126
}
125127

126128
writeTask = _outgoingMessages.OutputAvailableAsync(_linkedCancelSource.Token);

0 commit comments

Comments
 (0)