I decided to let player create game room.
When player clicks button create game, a signal is send to server, and server creates a game object. This game object is managed by using an arraylist.
The problem is if this game is destroyed, others player don’t know it was removed. They choose game from their lists and send it back to server.
If I send an object, I can use arraylist.contains(…) to determine if this game still exist or not. However, I think this way is not good because we must loop all array for each client request. This is not efficient (I assume we have a lot of players at the same time)
I move to other way. I send index of the game I choose. At server, I get the game with this index. If the comparison returns true, this game is still there and vice versa. It sounds good but new problem appears. Let see this example:
Game : a b c d e f
Index : 1 2 3 4 5 6
We remove c
Game : a b d e f
Index : 1 2 3 4 5
In this case, player chooses game “c”, we can definitely say “c” is out. If player chooses game “d”, he sends to server index 4. Now, 4 is game “e” and the comparison return false. We say game not existing, but its index is 3. It is still there.
Hic. I don’t know how to do. I hope receiving advice from you. Thx a lot.
Edited by KhoaVN, 13 October 2012 - 10:24 PM.