itisnajim / SocketIOUnity

A Wrapper for socket.io-client-csharp to work with Unity.
MIT License
379 stars 65 forks source link

Socket emit not passing data for some seconds #71

Open devalvitec opened 9 months ago

devalvitec commented 9 months ago

Hi ,

I am in the middle of game development and my game emits data for 30-40 seconds and then it pauses for some reason for almost 5-10 seconds and then whatever data I have emitted in those 5-10 seconds it's received all together in one go.

what might be the reason for that,

We have checked in the server with log and timestamp they says that Unity's socket call is not receiving to the server and as they receive all call at the same time server provide a response as one go.

any suggestion here on what might be the problem?

itisnajim commented 8 months ago

see with https://github.com/doghappy/socket.io-client-csharp

64jcl commented 7 months ago

I spent a couple of hours not understanding why I had similar problems and it boiled down to the fact that something silences all exceptions in socket.On() calls and furthermore you cannot reach the main thread objects through it - so you cant trigger anything in Unity directly from within the socket.On() function handler ! You have to store your response in a variable which you then read from e.g. OnUpdate to actually handle the message.

itisnajim commented 7 months ago

I spent a couple of hours not understanding why I had similar problems and it boiled down to the fact that something silences all exceptions in socket.On() calls and furthermore you cannot reach the main thread objects through it - so you cant trigger anything in Unity directly from within the socket.On() function handler ! You have to store your response in a variable which you then read from e.g. OnUpdate to actually handle the message.

u have to use socket.OnUnityThread instead of socket.On