- Home /
Gameplay gets buggy when application loses focus. What does Unity do automatically upon losing focus?
So the game I'm working on has a bit of client-server networking involved, but doesn't need constant communication with the server. When the game starts up and whenever something important in the game happens, the client sends a message to the server and the server sends data back to update the UI. The game cannot continue while we are waiting for a reply from the server.
The problem is that when the application loses focus and gets it back, we can still send messages to the server, but will no longer get any replies from the server, thus freezing gameplay.
If we set Application.runInBackground to true, we no longer get this problem on PC, but we still get the problem on iOS, which unfortunately is our target platform. There is a small possibility that this could be a problem with our server/client setup, but we're not expecting any messages to or from the server at the times the application loses focus, so I think it's more of a unity problem. Does anyone know what unity does exactly when it loses focus?
[EDIT] I forgot to mention that after we lose focus, the client can still send messages and the server DOES receive those messages and take the appropriate actions. The client, however, never receives the response from the server.
Your answer
Follow this Question
Related Questions
Send a Pause RPC on OnApplicationPause 1 Answer
Unity 5.0.2 iOS IL2CPP Networking RPC Issues 1 Answer
Connect to server with external and internal IP 0 Answers
ios Crash SetStatusCode() 0 Answers