Page 1 of 1

Simple issue: Join/Create Rooms

Posted: 22 Jan 2008, 11:57
by mistermind
This is probably real simple but I can't find a related topic about it on the search.
Here is the deal:
User enters in the lobby. If he is in a Clan, join a clan room. Clan Room does not exist? create Clan Room.
I first thought the best way would probably be around onJoinRoomError or onCreateRoomError (as the order on create/join doesn't make a difference since it will all end up the same way), BUT onJoinRoomError and onCreateRoomError do not have any useful parameters I can use since the only thing it fires is the error string message.

I'm pretty sure this issue has been address before and I'm positive I'm missing something since this is a very common thing to deal with multiplayer engines. The basic question is probably: is there a way to make "If room do not exist, create it. If it does, join it".

Posted: 23 Jan 2008, 09:42
by Bax
The best way to accomplish this task is on the server-side (in a custom extension), not on the client-side. Think about two users trying to join the same non-existing room. If you handle this on the client-side, this will probably happen:
- user A & B try to join;
- they both receive an error because the room is not existing;
- they both try to create it (but only one creation will be successful, for example the one performed by A);
- A will join the room, but B will receive an error in room creation.
Instead, if you handle everything on the client-side, you won't have concurrency (some tips: when a user wants to enter the Clan room, check if the room exists; if not, create it and then join the user, otherwise simply join it).