• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

App in background

Pfap

Member
I'm trying to find a way to still receive network data if the game loses focus. Or rather to store data on the other client if the player has pushed the game to the background.

The game is turn based.


Code:
if os_type == os_ios || os_type == os_android{
 if os_is_paused(){
 
  //let the other player know to que the outbound data
  var send_data = [];
  send_data[0] = background_handle;
  send_data[1] = -1;
  //code to trigger a send out
  var command = net_cmd_init("pushData");
  command[? "any_data"] = send_data
  net_cmd_send(command);
 
  alarm[1] = 30;
 }
}

The above code is supposed to send a command to the other player letting them know that there game has been pushed to the background. And then in the alarm[1] when the player brings the game back into focus, I send a command letting the other client know that I am back and can start receiving data again.

After reading the section on os_is_paused in the manual again, it seems to be that any code in the block after is ran when the game returns to focus. That is also what my debug results are showing, the game loses focus and the code doesn't run, the game regains focus and the -1 command is sent followed by the alarm firing.
Is there any way to send out a command just before being pushed to the background? Or will I need to resort to polling?
 
Top