Skip to content

Commit

Permalink
Merge pull request #43 from LagrangeDev/executor/fix-rws-payload-deco…
Browse files Browse the repository at this point in the history
…ding

[OneBot] Fix ReverseWS incorrectly decode received json payload
  • Loading branch information
Linwenxuan authored Nov 22, 2023
2 parents 3d0786e + ff668d7 commit 2972ad4
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions Lagrange.OneBot/Core/Network/Service/ReverseWSService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,12 @@ private async Task ReceiveLoop(ClientWebSocket ws, CancellationToken token)
while (true)
{
var result = await ws.ReceiveAsync(buffer.AsMemory(rcvd), token);
if (result.EndOfMessage) break;

rcvd += result.Count;
if (result.EndOfMessage) break;

if (rcvd == buffer.Length) Array.Resize(ref buffer, rcvd + 1024);
}
string text = Encoding.UTF8.GetString(buffer);
string text = Encoding.UTF8.GetString(buffer, 0, rcvd);
Log.LogDataReceived(_logger, Tag, text);
OnMessageReceived?.Invoke(this, new MsgRecvEventArgs(text)); // Handle user handlers error?
}
Expand Down

0 comments on commit 2972ad4

Please sign in to comment.