I have an issue I can't solve.
We have created a function so a user can create a regular room on the fly.
However, whenever 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
}
}