Page 1 of 1

ROOM_REMOVED is never fired

Posted: 14 Feb 2019, 11:19
by sadensmol
I have an event listener for ROOM_REMOVED event but when i remove the room from admin console this even isn't triggered.

I need the way to detect the room removal from admin console to refresh the rooms cache on the server.
Please help

Re: ROOM_REMOVED is never fired

Posted: 14 Feb 2019, 16:18
by Lapo
the event is triggered for Extensions at Zone level, meaning the Extension attached to the Zone containing the Room.

You can't listen for that event at Room level though, which I suspect could be the problem.
If you need to detect when the Room is destroyed from within the Room Extension, make sure to implement the destroy() method in your Extension.

Hope it helps

Re: ROOM_REMOVED is never fired

Posted: 15 Feb 2019, 05:42
by sadensmol
Hi, Lapo.
Thanks for the answer.

I have extension attached to the zone.

Code: Select all

    protected void initHandlers() {
        addEventHandler(SFSEventType.USER_LOGIN, SlotsLoginHandler.class);
        addEventHandler(SFSEventType.USER_JOIN_ZONE, UserJoinZoneHandler.class);
        addEventHandler(SFSEventType.USER_JOIN_ROOM, SlotsUserJoinedRoomHandler.class);
        addEventHandler(SFSEventType.USER_DISCONNECT, SlotsUserDisconnectsOrLogoutHandler.class);
        addEventHandler(SFSEventType.USER_LOGOUT, SlotsUserDisconnectsOrLogoutHandler.class);
        addEventHandler(SFSEventType.USER_LEAVE_ROOM, UserLeaveRoomHandler.class);
        addEventHandler(SFSEventType.PUBLIC_MESSAGE, PublicMessageHandler.class);
        addEventHandler(SFSEventType.ROOM_REMOVED, RoomRemovedHandler.class);

here is my room settings:

(36.62 KiB) Not downloaded yet

All other handlers are working well (login/join zone/ join room).

But when i delete the room from Admin Console I don't have RoomRemovedHandler working. Server doesn't execute it at all.
I suppose that maybe it's due to some room settings? Or Zone setting? When server just skips this event.
Any thoughts are welcome!

Thanks in advance.

Re: ROOM_REMOVED is never fired

Posted: 15 Feb 2019, 09:44
by Lapo
If you take a look at the configuration screenshot you've sent you will notice that the Room is set as isDynamic=false and the Room Remove Mode is set to NEVER_REMOVE.

This means that unless you remove the Room from your code calling Zone.removeRoom(...) the Room will never be destroyed.

Keep in mind that all Rooms defined in the AdminTool are stored statically in the config and considered static Rooms, in other words they persist during the whole life cycle of the server, as opposed to dynamically created Rooms which are eventually removed.

For more on this, see the documentation here: ... chitecture

Re: ROOM_REMOVED is never fired

Posted: 18 Feb 2019, 12:38
by sadensmol
Hi, Lapo.

Thanks for the answer.
Actually I don't want rooms to be dynamic and have any kind of auto removal option.
Im managing rooms by myself (some kind load balancing) - add new rooms from the code when needed, and remove when they aren't needed.
So in this case im okay that all rooms are static and have NEVER_REMOVE (automatically!) option.

We don't have any admin application in our project - so sometimes i need to remove rooms from SFS2x admin console (sometimes room logic freezes and we want just remove the room, handle this event and reconnect users to other rooms, and gracefully clean up the internal rooms cache for this room). I definitely say that Admin console removes the static rooms with NEVER_REMOVED setting just fine (so it destroys the room). Am i wrong on this?

is there any way to make rooms dynamic and NEVER_REMOVED and get Admin Console firing events during the manual rooms removal?

Re: ROOM_REMOVED is never fired

Posted: 18 Feb 2019, 16:27
by Lapo
I see what you're saying.
I've investigated the removal from AdminTool and it looks like we're not triggering the event (the necessary flag is turned off), so at the moment it doesn't provide a notification.

We can change that in the next patch. If you need it quickly we can send you a pre-release, provided you're using SFS2X 2.13.x

Let me know.

Re: ROOM_REMOVED is never fired

Posted: 19 Feb 2019, 07:03
by sadensmol
Hi, Lapo.

This is great! If possible please just update this thread when new functionality will be added to the admin tool and new release version will be shipped. I will update server or admin tool.
I will monitor your blog new releases posts and also this thread when it's ready.

Thanks a lot!

Re: ROOM_REMOVED is never fired

Posted: 19 Feb 2019, 07:52
by Lapo
Sure, I will post an update here.