Simple issue: Join/Create Rooms

Need help with SmartFoxServer? You didn't find an answer in our documentation? Please, post your questions here!

Moderators: Lapo, Bax

User avatar
Posts: 131
Joined: 15 Sep 2007, 01:33

Simple issue: Join/Create Rooms

Postby mistermind » 22 Jan 2008, 11:57

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".
User avatar
Site Admin
Posts: 4495
Joined: 29 Mar 2005, 09:50
Location: Italy

Postby Bax » 23 Jan 2008, 09:42

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).
Paolo Bax
The SmartFoxServer Team

Return to “SmartFoxServer 1.x Discussions and Help”

Who is online

Users browsing this forum: No registered users and 9 guests