deleting a room
deleting a room
I guess this is an extremely dumb question, but how do you force a room to be deleted? In the manual I see these methods:
createRoom
getRoom
leaveRoom
but no DeleteRoom or removeRoom
I need the users to always be connected to the main lobby so they can chat with all other players. They can also at this time create their own rooms to invite players to play with them (this I have done), but I need them to be able to delete these rooms as well, especially if they decide to join someone else's game.
It seems that allot of the example files just allow the dynamic rooms to time out? Leaving the room doesn't immediately cause the room to be deleted as far as I can tell.....
Sorry for such a basic question; I'm sure it's in an example some place, but I can't see it in the manual....
createRoom
getRoom
leaveRoom
but no DeleteRoom or removeRoom
I need the users to always be connected to the main lobby so they can chat with all other players. They can also at this time create their own rooms to invite players to play with them (this I have done), but I need them to be able to delete these rooms as well, especially if they decide to join someone else's game.
It seems that allot of the example files just allow the dynamic rooms to time out? Leaving the room doesn't immediately cause the room to be deleted as far as I can tell.....
Sorry for such a basic question; I'm sure it's in an example some place, but I can't see it in the manual....
Carl Lydon
Illustrator, animator, programmer
----------------------------------------
www.gametrust.com
www.chamberofchat.com
Illustrator, animator, programmer
----------------------------------------
www.gametrust.com
www.chamberofchat.com
What command does the admin tool use to destroy room?
What command does the admin tool use to destroy room?
I guess we don't have the source for that one...
Do you need to be an admin to destroy a room?
I guess we don't have the source for that one...
Do you need to be an admin to destroy a room?
Carl Lydon
Illustrator, animator, programmer
----------------------------------------
www.gametrust.com
www.chamberofchat.com
Illustrator, animator, programmer
----------------------------------------
www.gametrust.com
www.chamberofchat.com
You can delete room by user request by using server side extensions.
SFS destroys empty rooms automaticly. If the room is dynamic and it's NOT game room it's deleted when:
If they are game rooms:
So if rooms created by uour users are game room SFS behaviour(it deletes them if they are empty) is the same as the most game sites. So you don't need to type even a line of code to delete the empty rooms. Of cource you must write if you want to delete them by user request or in some other situation.
p.s. The above quotes are from the SFS docs. It's better to look in the docs since somethings may change and the above may be will not be true in the future. The first quote is from "5.5 Tutorials: Advanced Chat (part 2)" and the second is from "5.8 Tutorials: Board game (part 1)"
SFS destroys empty rooms automaticly. If the room is dynamic and it's NOT game room it's deleted when:
The second type of rooms can be dynamically created at runtime by the client using the SmartFoxClient API. These rooms can be destroyed by the server when there're no more users inside, and its creator isn't logged anymore in the zone.
This means that if all users have logged out of the room but its creator is still present in the zone the room will not be removed.
If they are game rooms:
What's the difference between a "regular" room and a "game" one? Almost no difference, however there is a slight difference in the behaviour when the room is empty. In the "Advanced Chat" tutorial we said that "regular" rooms are removed only when the last user exits and the room creator is not connected anymore in the zone. If the creator is still around the room will not be destroyed.
A game room behaves a little differently because it will be removed as soon as the last user leaves it. This is the ony difference.
So if rooms created by uour users are game room SFS behaviour(it deletes them if they are empty) is the same as the most game sites. So you don't need to type even a line of code to delete the empty rooms. Of cource you must write if you want to delete them by user request or in some other situation.
p.s. The above quotes are from the SFS docs. It's better to look in the docs since somethings may change and the above may be will not be true in the future. The first quote is from "5.5 Tutorials: Advanced Chat (part 2)" and the second is from "5.8 Tutorials: Board game (part 1)"
Default room behavior:
1- Regular rooms: are destroyed when empty and the owner is not connected to the server anymore (if owner == server, rooms are never destroyed)
2- Game rooms: are destroyed as soon as the last user inside leaves the room. (if owner == server, room is never destroyed)
From the admin tool you can destroy any room (even those owned by the server) but they have to be empty.
Same thing can be done using the _server.destroyRoom() from a custom extension
1- Regular rooms: are destroyed when empty and the owner is not connected to the server anymore (if owner == server, rooms are never destroyed)
2- Game rooms: are destroyed as soon as the last user inside leaves the room. (if owner == server, room is never destroyed)
From the admin tool you can destroy any room (even those owned by the server) but they have to be empty.
Same thing can be done using the _server.destroyRoom() from a custom extension
roomLost is firing twice??
SCENARIO:
I have lobbies (game rooms) where players can begin assembling teams of 3 players.
If the creator of one of these teams (game rooms) leaves the room, I want to boot any other players from the team back into the main lobby (regular room).
The system is configured to allow users to be in the main lobby and in the team lobby at the same time.
If the game creator leaves, I capture the event in a serverside extension and call leaveRoom to boot any remaining players. My code successfully boots the other players from the game room, and the game room is successfully deleted from the server.
THE PROBLEM:
the 'roomLost' internal event is firing twice when the creator of the room leaves. Naturally, the "onRoomDeletedHandler" then fires TWICE on the client side and thus causes problems with null values. (The 'room' param is null the second time through).
Here is a trace of the console that shows the event firing twice for the following situation.
1. User jd created the game room 'TeamLobby'
2. User md then joined the room
3. User jd (the creator) then leaves the room
I don't understand why 'roomLost' would fire twice here. Any ideas?? Here is my server side code:
Thanks!
Jonathan
I have lobbies (game rooms) where players can begin assembling teams of 3 players.
If the creator of one of these teams (game rooms) leaves the room, I want to boot any other players from the team back into the main lobby (regular room).
The system is configured to allow users to be in the main lobby and in the team lobby at the same time.
If the game creator leaves, I capture the event in a serverside extension and call leaveRoom to boot any remaining players. My code successfully boots the other players from the game room, and the game room is successfully deleted from the server.
THE PROBLEM:
the 'roomLost' internal event is firing twice when the creator of the room leaves. Naturally, the "onRoomDeletedHandler" then fires TWICE on the client side and thus causes problems with null values. (The 'room' param is null the second time through).
Here is a trace of the console that shows the event firing twice for the following situation.
1. User jd created the game room 'TeamLobby'
2. User md then joined the room
3. User jd (the creator) then leaves the room
Code: Select all
[login.as]: Event received: userExit
[teamLobby.as]: userExit User: jd left the TeamLobby
[login.as]: Event received: userExit
[teamLobby.as]: userExit User: md left the TeamLobby
02:08:17.476 - [ FINE ] > Shutting down extension: teamLobby
[teamLobby.as]: Extension Destroyed
[login.as]: Event received: roomLost - ROOM ID: 26
02:08:17.477 - [ INFO ] > Game Room Deleted: TeamLobby
[login.as]: Event received: roomLost - ROOM ID: 26
02:08:17.479 - [ INFO ] > Game Room Deleted: TeamLobby
I don't understand why 'roomLost' would fire twice here. Any ideas?? Here is my server side code:
Code: Select all
else if (eventName == "userExit" || eventName == "userLost"){
// Get the user from the local list
pi = evt.oldPlayerIndex
// If the team leader exits, boot the other players
if(pi == 1){
var user2 = playerList[2];
var user3 = playerList[3];
if(user2 != undefined){
_server.leaveRoom(user2, r.getId())
}
if(user3 != undefined){
_server.leaveRoom(user3, r.getId())
}
}
}
Thanks!
Jonathan
Code: Select all
[ RECEIVED ]: <msg t='sys'><body action='userGone' r='26'><user id='0' /></body></msg>, (len: 72)
[ RECEIVED ]: <msg t='sys'><body action='roomDel'><rm id='26'/></body></msg>, (len: 62)
[ RECEIVED ]: <msg t='sys'><body action='leaveRoom' r='-1'><rm id='26' /></body></msg>, (len: 72)
[ RECEIVED ]: <msg t='sys'><body action='roomDel'><rm id='26'/></body></msg>, (len: 62)
TypeError: Error #1009: Cannot access a property or method of a null object reference.
This is a trace with the SmartFoxClient debug enabled. You can see the null problem, it occurs in my handling of onRoomDeleted since the room param is null. Any thoughts?
This line of code is not clear:
every use leaving a room will fire a userExit event, so if two users are leaving room A you'll get that event twice.
Also in your code I don't see where this log:
is outputted.
Maybe could you submit a working example that produces the issue?
Code: Select all
else if (eventName == "userExit" || eventName == "userLost"){
every use leaving a room will fire a userExit event, so if two users are leaving room A you'll get that event twice.
Also in your code I don't see where this log:
[login.as]: Event received: roomLost - ROOM ID: 26
is outputted.
Maybe could you submit a working example that produces the issue?
Thanks for the reply,
The code segment you mentioned that was unclear is from a room extension called teamLobby.as.
This actually doesn't fire twice because I check that the playerId (pi) equals 1 (ensuring the player was the creator of the team).
login.as is a zone extension used for my custom login logic. Below is code from login.as that produces the output you mentioned:
Some of my trace statements have been changed for my own testing purposes so the output I've shown may not perfectly match up with the trace statement shown above.
The code segment you mentioned that was unclear is from a room extension called teamLobby.as.
every user leaving a room will fire a userExit event, so if two users are leaving room A you'll get that event twice.
This actually doesn't fire twice because I check that the playerId (pi) equals 1 (ensuring the player was the creator of the team).
Also in your code I don't see where this log:
[login.as]: Event received: roomLost - ROOM ID: 26
is outputted.
login.as is a zone extension used for my custom login logic. Below is code from login.as that produces the output you mentioned:
Code: Select all
function handleInternalEvent(evt)
{
trace("Event received: " + evt.name + " - ROOM ID: " + evt.roomId);
}
Some of my trace statements have been changed for my own testing purposes so the output I've shown may not perfectly match up with the trace statement shown above.
To provide more detail, the user joins a regular room called the Lobby. From here, the user can create a new game room (team lobby). Because it is a game room, the user is automatically joined and receives playerId = 1.
NOTE: I use exitCurrent = false when creating the game rooms to keep the user in the main lobby as well so that they can still chat etc. So users are thus in both the Lobby and the Team Lobby simultaneously.
Here is where I create the game room and attach the extension:
After other players join the game room, if the team creator leaves the room, the handleInternalEvent userLost / userExit event fires in teamLobby.as. This is where I call leaveRoom to boot any remaining players.
Even with three players in the room, the code successfully boots them all, the clients react appropriately, but because the 'roomLost' event fires twice, and thus the 'onRoomDeleted' event gets launched twice on the client causing problems.
UPDATE: I'VE ISOLATED THE EXACT PROBLEM BELOW
Thanks in advance for your time,
Jonathan
NOTE: I use exitCurrent = false when creating the game rooms to keep the user in the main lobby as well so that they can still chat etc. So users are thus in both the Lobby and the Team Lobby simultaneously.
Here is where I create the game room and attach the extension:
Code: Select all
// define team lobby server extension
var teamLobby:Object = {}
teamLobby.name = "teamLobby"
teamLobby.script = "teamLobby.as"
// create the new room
var roomObject:Object = new Object();
roomObject.name = duel_lobby_module.team_name_txt.text;
roomObject.maxUsers = 6;
roomObject.exitCurrent = false;
roomObject.isGame = true;
roomObject.extension = teamLobby;
After other players join the game room, if the team creator leaves the room, the handleInternalEvent userLost / userExit event fires in teamLobby.as. This is where I call leaveRoom to boot any remaining players.
Code: Select all
else if (eventName == "userExit" || eventName == "userLost"){
// Get the user from the local list
pi = evt.oldPlayerIndex
// If the team leader exits, boot the other players
if(pi == 1){
var user2 = playerList[2];
var user3 = playerList[3];
if(user2 != undefined){
_server.leaveRoom(user2, r.getId())
}
if(user3 != undefined){
_server.leaveRoom(user3, r.getId())
}
}
}
Even with three players in the room, the code successfully boots them all, the clients react appropriately, but because the 'roomLost' event fires twice, and thus the 'onRoomDeleted' event gets launched twice on the client causing problems.
UPDATE: I'VE ISOLATED THE EXACT PROBLEM BELOW
Thanks in advance for your time,
Jonathan
Last edited by jjduran on 04 Jun 2008, 01:33, edited 2 times in total.
So I spent the rest of the night working to isolate the problem and I finally found exactly where it is happening. Here is a scenario:
1. User jd creates the game room
2. User pac joins the room
3. User md joins the room
4. User jd (the creator) then leaves the room
When the userExit event triggers for the departure of user jd, the event is interrupted by the _server.leaveRoom calls. As you can see in the simplified trace below, the userExit event for jd does not finish until after the userExit events finish for users pac and md.
It seems that the extension finds no remaining users after booting player 3. Thus the extension is destroyed, but the code then seems to finish executing the first userExit event that was triggered when jd (the room creator) exited the room.
Below is the most recent teamLobby.as room extension that produced the above output:
I need some sort of workaround to stop the userExit event from continuing after the extension is destroyed. I hope this helps explain the issue.
THANKS!
1. User jd creates the game room
2. User pac joins the room
3. User md joins the room
4. User jd (the creator) then leaves the room
When the userExit event triggers for the departure of user jd, the event is interrupted by the _server.leaveRoom calls. As you can see in the simplified trace below, the userExit event for jd does not finish until after the userExit events finish for users pac and md.
Code: Select all
[teamLobby.as]: userExit BEGIN - Player: 1 User: jd
[teamLobby.as]: BOOT PLAYER 2
[teamLobby.as]: userExit BEGIN - Player: 2 User: pac
[teamLobby.as]: userExit FINISH - Player: 2 User: pac
[teamLobby.as]: BOOT PLAYER 3
[teamLobby.as]: userExit BEGIN - Player: 3 User: md
[teamLobby.as]: userExit FINISH - Player: 3 User: md
[teamLobby.as]: TeamLobby Extension Destroyed
[login.as]: ROOM LOST: 41
01:20:17.974 - [ INFO ] > Game Room Deleted: Team Lobby
[teamLobby.as]: userExit FINISH - Player: 1 User: jd
[login.as]: ROOM LOST: 41
01:20:17.981 - [ INFO ] > Game Room Deleted: Team Lobby
It seems that the extension finds no remaining users after booting player 3. Thus the extension is destroyed, but the code then seems to finish executing the first userExit event that was triggered when jd (the room creator) exited the room.
Below is the most recent teamLobby.as room extension that produced the above output:
Code: Select all
} else if (eventName == "userExit" || eventName == "userLost"){
// Get the user from the local list
pi = evt.oldPlayerIndex
u = playerList[pi]
trace("userExit BEGIN - Player: " + pi + " User: " + u.getName());
// If the team leader exits, boot the other players
if(pi == 1){
var user2 = playerList[2];
var user3 = playerList[3];
if(user2 != undefined){
trace("BOOT PLAYER 2);
_server.leaveRoom(user2, r.getId())
delete playerList[2]
}
if(user3 != undefined){
trace("BOOT PLAYER 3);
_server.leaveRoom(user3, r.getId())
delete playerList[3]
}
}
delete playerList[pi];
trace("userExit FINISH - Player: " + pi + " User: " + u.getName());
}
I need some sort of workaround to stop the userExit event from continuing after the extension is destroyed. I hope this helps explain the issue.
THANKS!
Thanks patso, but the destroy() function actually isn't the part that is being called twice... it is the 'roomLost' event that is being triggered twice.
Copied from my output above, you can see that the trace:
only fires once.
But the line:
fires twice
Any other ideas?
J
Copied from my output above, you can see that the trace:
Code: Select all
[teamLobby.as]: TeamLobby Extension Destroyed
But the line:
Code: Select all
01:20:17.974 - [ INFO ] > Game Room Deleted: Team Lobby
Any other ideas?
J
Return to “SmartFoxServer 1.x Discussions and Help”
Who is online
Users browsing this forum: No registered users and 50 guests