endel / NativeWebSocket

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

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

Open zach-r-d opened 2 years ago

zach-r-d commented 2 years 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.