Room not getting destroyed

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

Moderators: Lapo, Bax

arun8483
Posts: 33
Joined: 15 Dec 2010, 02:35
Contact:

Room not getting destroyed

Postby arun8483 » 21 Mar 2012, 21:11

hi,
This is how I am creating my room in server side(java)
newRoom = helper.createRoom(currZone, map, null, roomVars, null, false, true, true);
This is how I am trying to destroy the room

Code: Select all

private void destroyRoom(ExtensionEnum extensionEnum) {
        trace("***destroyRoom*****");
        trace("extensionEnum ["+extensionEnum.getValue()+"]");
        if (extensionEnum == ExtensionEnum.USER_LOST) {
            trace("currentRoom.getUserList().length ["+currentRoom.getUserList().length+"]");
            if (currentRoom.getUserList().length == 1) {
               
                    trace("destroying");                   
                    helper.destroyRoom(currZone, currentRoom.getId());
               
            }
        } else {
            trace("currentRoom.getUserList().length ["+currentRoom.getUserList().length+"]");
            if (currentRoom.getUserList().length == 0) {
               
                    trace("destroying");                   
                    helper.destroyRoom(currZone, currentRoom.getId());
               
            }
        }

    }


But room is not getting destryed..even after calling destroyRoom method...room still exists...
Also, in User_Lost event, room count always stays at "1"...is that the reason why its not getting destroyed???
arun8483
Posts: 33
Joined: 15 Dec 2010, 02:35
Contact:

Re: Room not getting destroyed

Postby arun8483 » 21 Mar 2012, 21:16

Yes, I've double checked it...
In User_exit,,,I am getting the count as 0..and destroyRoom method call works fine....
But in User_Lost, I am getting the count as 1..and destroyRoom method call fails...room always exists in memory.
I am using Room level extension and I am doing all this logic inside handleInternalEvent method.
User avatar
rjgtav
Posts: 2813
Joined: 19 Apr 2009, 11:31
Location: Lisbon, Portugal

Re: Room not getting destroyed

Postby rjgtav » 21 Mar 2012, 23:33

Hi. Please keep the conversation in one topic. Unfortunately today I didn't had the time to test it. Tomorrow I'll do some tests and report back to you the results. In the mean time, please make sure that you're using the latest SFS PRO 1.6.9. Probably, the server isn't destroying the room because it detects that there are still some users joined in...

[EDIT]
After searching for a while, it looks like this is the expected behaviour, as that event gets fired on the extension before the user actually disconnects. Anyway, in this specific scenario, you have 2 options to solve your problem:
- use user owned rooms - in this case the room manager will automatically clean all the empty rooms, when their owner leaves;
- use server owned rooms - in this case, it is a little more difficult. Usually it is better to create an interval on your zone-level extension, which runs every some minutes (5-10mins?) and each time it runs, it checks all the rooms and if they're empty, it destroys them.
You can always try as it suggests on the docs here and manually remove the user from the room's userList before you try to destroy the room. I bet that way you'll be able to successfully remove the room.
Skills: SFS Pro, SFS2X, AS2.0/AS3.0, Java, HTML5/CSS3/JS, C#
Portfolio: https://rjgtav.wordpress.com/
SFS Tutorials: http://sfs-tutor.blogspot.com/ - Discontinued. Some examples may be bugged.
arun8483
Posts: 33
Joined: 15 Dec 2010, 02:35
Contact:

Re: Room not getting destroyed

Postby arun8483 » 22 Mar 2012, 07:49

Yes,,,correct I have solved it..thanks
First I have to call room.removeUser(user)
then destroyRoom method call...

Return to “SmartFoxServer 1.x Discussions and Help”

Who is online

Users browsing this forum: No registered users and 29 guests