Room creation issue: paid solution/fix

SmartFoxServer gurus looking for a new job and companies looking for multi-player developers, this is the right place to meet!

Moderators: Lapo, Bax

Post Reply
zerokuhhl
Posts: 7
Joined: 05 Aug 2010, 20:03

Room creation issue: paid solution/fix

Post by zerokuhhl »

Hello folks,

I know this has been previously posted, however I really need help with this.

I have a live system and the create room function for my users is hiccuping big time and I'm in desperate need of a solution.


We have created a function so a user can create a regular room on the fly. However, whenever this new room is created, all existing users become auto joined to that newly created room automatically.
All the users get ported to that created room and duplicates of the users stay in the rooms they were in.


What are we doing wrong?

This is the code that is placed client side in the interface.

Code: Select all

public function createRoom(roomName:String, auto_join:Boolean):Void {
 
 
  this._targetRoomName = roomName;
  trace("function createRoom called");

 
  var gameRoom:Object  = new Object()
  gameRoom.name    = roomName
  gameRoom.password   = ''
  gameRoom.maxUsers   = 12
  gameRoom.maxSpectators  = 0;
  gameRoom.isGame   = false
  gameRoom.isTemp   = false
  gameRoom.isDynamic  = true
 
 

 
  var MapPath = _root.selectedroompath_raw+""+_root.selectedindex;
  trace("create room function trigered "+roomName+" and mappath = "+MapPath);
  var vars:Array = new Array()
  vars.push( {name:"MapPath", val:MapPath} )
  gameRoom.vars = vars;
  this.onUserCountChange();
 

  this._fox.onRoomAdded = onRoomAddedHandler

  var found = false;
  var result:Array = new Array();
 
  for(var i in this._fox.roomList){
   var r:TheoRoomData = new TheoRoomData();
   r.name = Room(this._fox.roomList[i]).getName();
   
   if(roomName == Room(this._fox.roomList[i]).getName())
   {
    found = true;
    //getURL("javascript:alert('room exists = "+Room(this._fox.roomList[i]).getName()+"');");
   }

  }
 
  if(found)
  {
          this.joinRoom(roomName,"");
  }else
  {
   var roomcreating_result = this._fox.createRoom(gameRoom,null)
   
  }
 

   
  function onRoomAddedHandler(room:Room):Void
      {
       trace("Room " + room.getName() + " was created")
     this._fox.setRoomVariables(room.getVariables())
     this.joinRoom(room.getName(),"");
       //getURL("javascript:alert(' created room = "+room.getName()+"');");
       // TODO: update available rooms list in the application interface
     }
   
 
 } 
User avatar
rjgtav
Posts: 2813
Joined: 19 Apr 2009, 11:31
Location: Lisbon, Portugal

Post by rjgtav »

hi. Can you paste here the link to the post about this issue? Currently your code seems to be ok. How are you checking if the users stay in the previous room? Via adminTool? If not, pls check with it

EDIT. Dont need to paste here the link. Already found it. Btw, i.ll help from there
Skills: SFS Pro, SFS2X, AS2.0/AS3.0, Java, HTML5/CSS3/JS, C#
Portfolio: https://rjgtav.wordpress.com/
SFS Tutorials: http://sfs-tutor.blogspot.com/ - Discontinued. Some examples may be bugged.
Satyarth
Posts: 131
Joined: 06 Nov 2008, 12:45
Location: Delhi, India
Contact:

Issue

Post by Satyarth »

It seems onRoomAddedHandler is called on all clients whenever a new room is added. So all clients join the room. You can check only the owner of room joins it in onRoomAddedHandler ... or you can change the name of the handler etc

Well can be solved in many ways. Ping me if you need more help. My skype id is satyarthnegi
Post Reply