endel / NativeWebSocket

🔌 WebSocket client for Unity - with no external dependencies (WebGL, Native, Android, iOS, UWP)
Other
1.13k stars 155 forks source link

Perform array copies outside of `lock`s in Receive #69

Open zach-r-d opened 1 year ago

zach-r-d commented 1 year ago

Call ms.ToArray() outside of the lock (IncomingMessageLock) sections in Receive(). This prevents the Unity main thread blocking on IncomingMessageLock if ms.ToArray() is copying a large number of bytes.