Something strange about getRoomList()?

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

Moderators: Lapo, Bax

JCRobinson
Posts: 14
Joined: 30 Nov 2008, 00:35

Something strange about getRoomList()?

Postby JCRobinson » 05 Dec 2008, 21:32

Hi all

I have been working with smart fox over the past month and have had no problems. However something that has baffled me is what the getRoomList(); dose?

I assumed that getRoomList would update the room list. So that when I use getAllRooms I should have an upto date array of the rooms from the zone.. But this dose not seem to be the case... Even after I have updated the room list with getRoomList I still don't have the correct data in the array...

Is this a normal problem or am I missing something?
JCRobinson
Posts: 14
Joined: 30 Nov 2008, 00:35

I think I found the problem

Postby JCRobinson » 05 Dec 2008, 21:55

I think I found the problem I cant detect with the dynamically created rooms because I have isGame = true; in the room object used to create the rooms. I used this because it automatically joins the room.

However I cant seem to manually join the room directly after creating it. I'm using this joinRoom(e.roomName) directly after createRoom(roomObj); should this work?

also e.roomName is my event not smartfox
Last edited by JCRobinson on 05 Dec 2008, 23:11, edited 1 time in total.
JCRobinson
Posts: 14
Joined: 30 Nov 2008, 00:35

Getting there slowly..

Postby JCRobinson » 05 Dec 2008, 23:09

I stuck a timer on the joinRoom() after the createRoom() was run. This has kind of solved the problem for meantime but will have to find a better method, and I now have other problems.

I'm still not receiving an upto date version of the zones rooms list. Which is resulting in errors being sent by the server. As smart fox is trying to create rooms that already exist!

I noticed that normal rooms don't self destruct like game rooms, I think I can dig this out of the forum posts but a pointer would be handy.
User avatar
mistermind
Posts: 131
Joined: 15 Sep 2007, 01:33
Contact:

Re: Getting there slowly..

Postby mistermind » 06 Dec 2008, 01:13

JCRobinson wrote:I stuck a timer on the joinRoom() after the createRoom() was run. This has kind of solved the problem for meantime but will have to find a better method, and I now have other problems.

I'm still not receiving an upto date version of the zones rooms list. Which is resulting in errors being sent by the server. As smart fox is trying to create rooms that already exist!

I noticed that normal rooms don't self destruct like game rooms, I think I can dig this out of the forum posts but a pointer would be handy.



I see where you're having trouble. Rather then stuck a timer, use this event produced by SFS:
smartfox.onRoomAdded = function(roomObj:Room)
The only rooms that allow auto-join are rooms with the isGame set to true. Regular rooms need to use this SFS event to proceed.

Here is a small yet effective example:
Your client will try creating a clan room called "My Clan Room" and then join it. If the room already exists (meaning some other clan member already created that room) they will join the room instead. Rooms created dynamically are destroyed as soon as the last user leaves.

Unfortunately since onCreateRoomError and onJoinRoomError events do not transmit the id or name of the room you are trying to create, you have to rely on global vars to let your client communicate between events.

In the example above I only use onCreateRoomError. If you want I can give you a more extensive example using onJoinRoomError, but I think you will get the picture.

Code: Select all

creatingRoom = "";

smartfox.onRoomAdded = function(roomObj:Room){
   roomName = roomObj.getName();
   if (creatingRoom == "clan" && roomName == "My Clan Room"){
      smartfox.joinRoom(roomObj.getId(),"",false,true);
      creatingRoom = "";
   }
}

smartfox.onCreateRoomError = function(errorMsg){
   if (creatingRoom == "clan"){
      var clanRoom:Room = smartfox.getRoom("My Clan Room");
      smartfox.joinRoom(clanRoom.getId(),"",false,true);
      delete clanRoom;
      creatingRoom = "";
   }
}

smartfox.onJoinRoom = function(roomObj:Room){
   if (roomObj.getName()=="My Clan Room"){
      textBox.htmlText = "WELCOME!";
      creatingRoom = "";
   }
}

creatingRoom = "clan";
var room:Object = new Object;
room.name = "My Clan Room";
room.password = "";
room.maxUsers = 10000;
smartfox.createRoom(room);


This should also help you:
http://www.smartfoxserver.com/docs/docP ... createRoom
SELECT * FROM users WHERE clue > 0
0 rows returned.
JCRobinson
Posts: 14
Joined: 30 Nov 2008, 00:35

much more clear about onRoomAdded

Postby JCRobinson » 06 Dec 2008, 12:18

Hi, mistermind

Thanks for that, its much more clear that onRoomAdded
broadcasts the new room to all connected clients, and I can see a better way of handling the rooms using an array. This will also stop the error message appearing in the SFS Server console, when a room already exists.

I noticed you said that "Rooms created dynamically are destroyed as soon as the last user leaves", however in my case they stay. The rooms only delete if the user who created them discontents. I'm looking into this at the moment within this forum, but I'm wondering if anyone has had the same problem?

I just dug this out of the documentation within the “Application Architectureâ€
User avatar
mistermind
Posts: 131
Joined: 15 Sep 2007, 01:33
Contact:

Postby mistermind » 08 Dec 2008, 13:59

Just got some confirmation here. Dynamic rooms are only destroyed when everyone leaves regardless or being the owner or not.
I actually was almost 100% positive otherwise I would definitely have some bugs on my game by now.
SELECT * FROM users WHERE clue > 0

0 rows returned.
JCRobinson
Posts: 14
Joined: 30 Nov 2008, 00:35

Thanks again, mistermind

Postby JCRobinson » 08 Dec 2008, 15:40

Thanks again, mistermind

It must be something my end that stops the rooms being destroyed. Anyway I did a bit of brain storming and realize the need for multiple rooms is not needed. I found that I can split the users into multiple groups within one room.

This then minimizing the need for multiple rooms per individual user, It also allows the Regular room to be used within the way I foreseen as the generation of rooms for multiple clients is no longer needed.

What kind of game have you made?

John

Return to “SmartFoxServer 1.x Discussions and Help”

Who is online

Users browsing this forum: No registered users and 78 guests