I'm building a Unity3D client in C# for a multiplayer game that I made. The server is written in Node.js, and I wrote a web client in Javascript that works well. But I am running into lag issues with my Unity3D client implementation. I am using the websocket-sharp library, but have been unable to use it in the same way as I did on my Javascript client with the HTML5 Websocket class. I believe the issue lies in the way the websocket-sharp library is made, currently each Send() will cause a lock to _forSend, so the data will transmit like this:
data1:frg1
data1:frg2
data2:frg1
data2:frg2
...
But on my working javascript implementation, it looks like this as it is truly multithreaded:
data1:frg1
data2:frg1
data2:frg2
data1:frg2
Therefore I believe this is the cause of my lag with my C# Unity implementation, because the websockets-sharp library behaves like this. Can anyone confirm that this is an issue with the websockets-sharp library or suggest a library that would work?
Send
here, but it seems like your looking forSendAsync
behavior – Driving