Findig a reliable Master on Android
Options
Have been using "isMaster" to set various in game variables, but if an Android device is master and it goes to sleep or is bumped into background, then it never releases its Master status, no other player can take over master status, so game stalls. Master is still recorded as active after 30 min or more sleeping.
Any clues on how I can get a reliable (present) Master?
Do I just try to poll the lowest present ID number? an easy way to do this?
Background:
I am setting up a race between a group of players that lasts say 10 min, then the "Master" kicks off another race (with different variables). If the Master has gone to sleep, no new race ever starts.
I have been trying to do a workaround using "Photon Network time" on "lobby" and also "room" and recording times in an external online database and then comparing them whenever a player goes to lobby. During the race all players monitor room time via same mechanism, but I am ending up in a world of hurt as the time in lobby and rooms are all on different servers and are all different. I also have to force all players back to the lobby for each new race and create a new room for each race, which is all yuk!
Any clues on how I can get a reliable (present) Master?
Do I just try to poll the lowest present ID number? an easy way to do this?
Background:
I am setting up a race between a group of players that lasts say 10 min, then the "Master" kicks off another race (with different variables). If the Master has gone to sleep, no new race ever starts.
I have been trying to do a workaround using "Photon Network time" on "lobby" and also "room" and recording times in an external online database and then comparing them whenever a player goes to lobby. During the race all players monitor room time via same mechanism, but I am ending up in a world of hurt as the time in lobby and rooms are all on different servers and are all different. I also have to force all players back to the lobby for each new race and create a new room for each race, which is all yuk!
0
Best Answer
-
ok, thanks heaps for this fix in latest version, Only trick is that you have to actually set the value in PhotonNetwork to something other than "0".
public static float BackgroundTimeout = 0.0f;
Might be nice to default it to say 10secs?
On a side note, I wish I was a better programmer so haven't lost weeks coding dodgy workarounds and banging my head against the wall.
Anyway, will rewrite my code now without the dodgy bits.
Still, thanks heaps for the fix and Robertsze for his input. I am singing on the road again.5
Answers
-
Do you use latest PUN version? The issue should be fixed already.
You can find more details in discussion: http://forum.photonengine.com/discussion/6680/idle-android-players#latest0 -
I tested it with the latest Demo off asset store ie 1.62 or 1.63? (see other version post).
Used ownership transfer demo ... if a slave leaves and returns it is assigned a new ID & colour (perfect). If the master (android) leaves it stays listed on other running copy (my editor) for over 30 min. Will explore link above.0 -
The test was done in new project of Unity, to avoid any of my code hanging around.0
-
ok, thanks heaps for this fix in latest version, Only trick is that you have to actually set the value in PhotonNetwork to something other than "0".
public static float BackgroundTimeout = 0.0f;
Might be nice to default it to say 10secs?
On a side note, I wish I was a better programmer so haven't lost weeks coding dodgy workarounds and banging my head against the wall.
Anyway, will rewrite my code now without the dodgy bits.
Still, thanks heaps for the fix and Robertsze for his input. I am singing on the road again.5 -
and another little bit is needed to come back after going to sleep....
In the DemoChangeOwner demo ... I added the following to ConnectAndJoinRandom.cs to allow a re-connection and return to game (if that is what you want).
protected void OnApplicationPause(bool pause)
{ //false when coming out of pause state
if(!pause)
{
ConnectInUpdate = true;
}
}0