Skip to content

Commit 64867d4

Browse files
kazimuthGuribo
andauthored
Recreate #311 (#317)
## Description of Changes Recreating #311 using a branch in this repo in the hope of fixing the Unity build. ## API - [ ] This is an API breaking change to the SDK ## Requires SpacetimeDB PRs ## Testsuite SpacetimeDB branch name: master ## Testing - [x] blackholio - [ ] bitcraft --------- Co-authored-by: Guribo <[email protected]>
1 parent 2503ff9 commit 64867d4

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/WebSocket.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ public WebSocket(ConnectOptions options)
5050
public event OpenEventHandler? OnConnect;
5151
public event ConnectErrorEventHandler? OnConnectError;
5252
public event SendErrorEventHandler? OnSendError;
53+
54+
/// <summary>
55+
/// Called directly by background task (not on main thread!)
56+
/// </summary>
5357
public event MessageEventHandler? OnMessage;
5458
public event CloseEventHandler? OnClose;
5559

@@ -337,7 +341,8 @@ await Ws.CloseAsync(WebSocketCloseStatus.MessageTooBig, closeMessage,
337341
if (OnMessage != null)
338342
{
339343
var message = _receiveBuffer.Take(count).ToArray();
340-
dispatchQueue.Enqueue(() => OnMessage(message, startReceive));
344+
// directly invoke message handling
345+
OnMessage(message, startReceive);
341346
}
342347
}
343348
catch (WebSocketException ex)

0 commit comments

Comments
 (0)