onJoinRoomError handler

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

onJoinRoomError handler

Postby mistermind » 25 Feb 2008, 21:38

I can see that the only variable sent to this event is the error message generated by the server, but would it be possible to add extra information both onJoinRoomError and onCreateRoomError? Currently the only way I can tell in which case things went wrong is if I set a variable before the room creation, and check which room caused the error by checking that variable behavior.

onJoinRoomError(roomId: number, errorMsg: String)
onCreateRoomError(roomId: number, errorMsg: String)

If that is not possible, would that be a better way then what I'm doing right now?
User avatar
Site Admin
Posts: 21362
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 26 Feb 2008, 14:40

You don't get details about the room which caused the error because it is unlikely that you're joining more than one room at a time.
When the error is fired the roomId should be the one of the room you have attempted to join.

Makes sense?
More details are logged on the server side.
...addicted to flash games
User avatar
Posts: 131
Joined: 15 Sep 2007, 01:33

Postby mistermind » 26 Feb 2008, 16:39

Hey Lapo :)
Yea that makes total sense. In fact my code handles join and creation one step at the time, which made the internal client variable control a lot easier. The only problem is that it gets a little unsafe to handle these scenarios based on internal variables instead of server responses. I mean, I got to a point where onJoinRoomError and onCreateRoomError are the key to handle concurrency, but in order to do that I had to make two variables called "joiningRoom" and "creatingRoom", that is basically fired when a user tries to join a room. Here is an example of trying to create a clan room, and if exists, he joins it.

Code: Select all

_root.creatingRoom = "clan";
var room:Object = new Object;
room.name = clan;
room.password = "";
room.exitCurrentRoom = false;
room.maxUsers = 10000;

// If some other member have already created it, just join.
smartfox.onCreateRoomError = function(errorMsg){
   if (creatingRoom == "clan"){
      var clanRoom:Room = smartfox.getRoom(clan);
      delete clanRoom;
      delete creatingRoom;

The example above is a general idea on how I'm taking advantage of both events, but since there is no extra information on them, I'm forced to handle these issues client side, making it unsafe, highly buggy and crackable.

Return to “SmartFoxServer 1.x Discussions and Help”

Who is online

Users browsing this forum: No registered users and 15 guests