Forum Multiplayer Error with sync or something else

Discussion and help relating to the PlayerIO Multiplayer API.

Error with sync or something else

Postby gnollik » June 8th, 2011, 12:04 pm

Hello!

I`m developing a game and this is how it works:

1. User connect to the server, join to the main room and wait "start".
2. When playercount in the main room is 3, the server send a name of the game room to all connected players.
3. All 3 players disconnect from the main room and connect to a new game room.
4. game start.

And all works fine while I`m use the limit on players not more than 3. But when I`m try to change it to 5, some players doesnt connect to the server. Sometimes they dont get "start" from the server (80%), and sometimes they get it but cant connect to the new game room (20%).

This is a code that I`m use on server side:

if (PlayerCount == 3)
{
this.timer2 = AddTimer(delegate
{
PlayerIO.BigDB.Load("racer", "game_name", delegate(DatabaseObject user)
{
game_count = user.GetInt("count", 0);
user.Set("count", game_count + 1);
user.Save();
foreach (Player u in this.Players)
{
u.Send("start", game_count, info_list);
}
});
}, 3000);
}

I`m add timer because I thnk that this may help to sync players but it doesnt help.. (

If you need I can provide you all code with my connect from AS3 and the server side code too.

Please advice what can be the reason of this issue...
gnollik
Paid Member
 
Posts: 24
Joined: March 12th, 2011, 10:08 pm

Re: Error with sync or something else

Postby Oliver » June 9th, 2011, 11:15 am

Hi,

I cannot reproduce this behavior. I tried building a minimal test rig that does exactly what you describe, and it works perfectly for me. Is it possible that you have other logic that's interfering with your target behavior?

I've attached the source.

Best,
Oliver

TEsT.zip
(1.79 MiB) Downloaded 1194 times
User avatar
Oliver
.IO
 
Posts: 1159
Joined: January 12th, 2010, 8:29 am

Re: Error with sync or something else

Postby Oliver » June 9th, 2011, 11:17 am

Hey,

I made a last minute edit in the source and forgot a semicolon. In game.cs line 24, just add the semicolon. It still works.

- Oliver
User avatar
Oliver
.IO
 
Posts: 1159
Joined: January 12th, 2010, 8:29 am

Re: Error with sync or something else

Postby gnollik » June 9th, 2011, 3:18 pm

Oh, it looks like this issue was because I`m try to use "foreach (Player u in this.Players)". I`m change it on "Broadcast" and it works fine for 5 players now. I`ll test it later.

thanks for your help ).
gnollik
Paid Member
 
Posts: 24
Joined: March 12th, 2011, 10:08 pm

Re: Error with sync or something else

Postby Oliver » June 10th, 2011, 11:10 am

Hey,

I just changed my example to use "foreach(var p in Players)" and it still works, so it has to be something else.

Best,
Oliver
User avatar
Oliver
.IO
 
Posts: 1159
Joined: January 12th, 2010, 8:29 am

Re: Error with sync or something else

Postby gnollik » June 10th, 2011, 1:03 pm

Yes, maybe you are right and the problem was in something else, but I`m already test my game with broadcast and it works fine for 5 players, so I`m already sent it to my client. In future I will check this once again with "foreach", but not now. I will write about it in this theme.

Thanks again for your help )
gnollik
Paid Member
 
Posts: 24
Joined: March 12th, 2011, 10:08 pm


Return to Multiplayer