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?
Something strange about getRoomList()?
-
- Posts: 14
- Joined: 30 Nov 2008, 00:35
-
- Posts: 14
- Joined: 30 Nov 2008, 00:35
I think I found the problem
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
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.
-
- Posts: 14
- Joined: 30 Nov 2008, 00:35
Getting there slowly..
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'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.
- mistermind
- Posts: 131
- Joined: 15 Sep 2007, 01:33
- Contact:
Re: Getting there slowly..
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.
0 rows returned.
-
- Posts: 14
- Joined: 30 Nov 2008, 00:35
much more clear about onRoomAdded
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â€
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â€
- mistermind
- Posts: 131
- Joined: 15 Sep 2007, 01:33
- Contact:
-
- Posts: 14
- Joined: 30 Nov 2008, 00:35
Thanks again, mistermind
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
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