Basic - delete room

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

Moderators: Lapo, Bax

enzor
Posts: 15
Joined: 27 Aug 2007, 14:36
Location: Hungary
Contact:

Basic - delete room

Postby enzor » 30 Aug 2007, 11:44

Hi!

I got another problem.
create a room dynamicly, I attach an exit button, which works – when I click on it, i quit the room, but the room stlil exists after that.
The isTemp variable is set to „true”

Can you help me solve the problem?

THX!

Here is the as:

Code: Select all

//----------------------------------------------------------
// CreateRoom
//----------------------------------------------------------

function createRoom(name:String, pwd:String, max:Number)
{
   hideWindow("newRoomWindow")
   
   var roomObj:Object = new Object()
   var RoomVars:Array = new Array();
   
   roomObj.name       = name
   roomObj.password   = pwd
   roomObj.maxUsers   = max
   roomObj.isTemp   = true
   
   RoomVars.push( {name:"creatorName", val:_global.myName, priv:false, persistent:true} )
   roomObj.vars = RoomVars;
   
   smartfox.createRoom(roomObj)
   
}


//----------------------------------------------------------
// Handles a new room added to the zone
//----------------------------------------------------------
smartfox.onRoomAdded = function(roomObj:Room)
{
   if(roomObj.getName()!="limbo"){
      roomList_lb.addItem(roomObj.getName() + " (" + roomObj.getUserCount() + ")", roomObj.getId())
   }
   
   //IF IAM THE CREATOR, ENTER IN THE ROOM
   if(_global.myName == roomObj.getVariable("creatorName")){
      smartfox.joinRoom(roomObj.getName())
   }

   roomCount++
   if(roomCount==MaxRoomNumber){
      new_btn.enabled=false
      new_btn._alpha=30
      alert_msg.text="minden szoba foglalt"
   }else{
      new_btn.enabled=true
      new_btn._alpha=100
      alert_msg.text="szabad helyek szama: "+(MaxRoomNumber-roomCount)
   }
   
   roomList_lb.sortItemsBy("label", "ASC")
   
}


//----------------------------------------------------------
// onJoinRoom
//----------------------------------------------------------

smartfox.onJoinRoom = function(roomObj:Room)
{
   

   if(roomObj.getName() != "limbo"){
      //EXIT TO LIMBO ROOM
      attachMovie("exitbutton","exitbutton", getNextHighestDepth())
      exitbutton.onRelease = function(){
         
//leave the current room and enter in the limbo
         smartfox.joinRoom("limbo")

         var A_room:Room = smartfox.getActiveRoom()

         trace("activeroom="+A_room.getName()) //gives activeroom = myNewRoom
         // now i’am int he limbo room, but myNewRoom is there in the list yet (myNewRoom(0))
         removeMovieClip("exitbutton")
      }
   }
   
   var roomId:Number   = roomObj.getId()
   var userList:Object   = roomObj.getUserList()
   
   resetRoomSelected(roomId)
   
   _global.currentRoom = roomObj
   
   // Clear text area
   chat_txt.htmlText = ""
   
   // Clear current list
   userList_lb.removeAll()
   
   for (var i:String in userList)
   {
      var user:User = userList[i]
      userList_lb.addItem(user.getName(), user.getId())
   }
   
   // Sort names
   userList_lb.sortItemsBy("label", "ASC")
   
   if(roomObj.getName()!="limbo"){
      chat_txt.htmlText += "<font color='#cc0000'>Beléptél a  [ " + roomObj.getName() + " ] szobába</font>";
   }
}
Last edited by enzor on 06 Sep 2007, 07:40, edited 2 times in total.
User avatar
darnpunk
Posts: 229
Joined: 22 Jun 2007, 02:58
Location: SG

Postby darnpunk » 31 Aug 2007, 00:40

You can refer to http://www.smartfoxserver.com/docs/index.htm?http://www.smartfoxserver.com/docs/docPages/extIntro/roomArchitecture.htm to read up more on Rooms. I believe that if you create a Regular room and still connected to the server, the room will not be deleted automatically even if there is no one else in the room.

However for Game rooms, when the last user leaves the room, the room is automatically deleted from server.

If you want to achieve this with regular room, you should do it through server extensions. Unless there is a method that I am unaware of. Take a look at the link :wink:

Regards,
darnpunk
enzor
Posts: 15
Joined: 27 Aug 2007, 14:36
Location: Hungary
Contact:

Postby enzor » 04 Sep 2007, 09:10

Hi!

REGULAR:
A regular room that was created dynamically is destroyed when it is empty and its owner has left the server.

When i set the isTemp value in the config.xml, then it works,
<Room name="temp" autoJoin="true" isTemp="true" maxUsers="100"/>
but when I create it dynamically, it fails to work.
this is the problem.

question 2:
how can i destroy dynamically a room? it is possible?

grazie!
enzor
User avatar
Lapo
Site Admin
Posts: 23026
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 04 Sep 2007, 16:19

Hi, what are the the characteristics of the dynamic room?
game or not?
limbo or not?
how is it created client side or server side?
who's the owner?

Please use the Code button to format the code snippets or they become pretty unreadable

thnx

p.s. = dynamic rooms can be destroyed from the server side, provided that they are empty. This is usually only needed when the room was created from the server side with a null owner object (which means that the server is the owner)
Lapo
--
gotoAndPlay()
...addicted to flash games
enzor
Posts: 15
Joined: 27 Aug 2007, 14:36
Location: Hungary
Contact:

Postby enzor » 06 Sep 2007, 08:00

Hi!

not game
not limbo
client side created.

dynamic rooms can be destroyed from the server side, provided that they are empty


I would like to obtain if there is nobody in the room, then delete it automatically.

_server.destroyRoom() is the solution?
http://www.smartfoxserver.com/docs/docP ... /index.htm

thx!
enzor
Posts: 15
Joined: 27 Aug 2007, 14:36
Location: Hungary
Contact:

Postby enzor » 07 Sep 2007, 07:34

I've got only the basic version.
it doesn't contain sever side extensions :-(

Then how can I do it whit basic?

thx!

Return to “SmartFoxServer 1.x Discussions and Help”

Who is online

Users browsing this forum: No registered users and 60 guests