USER_LEAVE_ROOM is not fired on user logout

Post here your questions about SFS2X. Here we discuss all server-side matters. For client API questions see the dedicated forums.

Moderators: Lapo, Bax

Post Reply
mente
Posts: 73
Joined: 14 Apr 2011, 14:27

USER_LEAVE_ROOM is not fired on user logout

Post by mente »

Hello,

On user logout, USER_LEAVE_ROOM client event is fired to each room, where the user was. However server event is not fired.
Is it a bug or a feature? If it's a feature, then can you explain why? Or is there any workaround for server event in this case?
If it's a bug, please fix it :).

Log for normal user leave room:

Code: Select all

15:34:34,660 DEBUG [com.smartfoxserver.v2.controllers.SystemController-1] managers.SFSRoomManager     - User: account-1 removed from Room: game-1017
15:34:34,661 DEBUG [com.smartfoxserver.v2.controllers.SystemController-1] protocol.SFSProtocolCodec     - {OUT}: OnUserExitRoom
15:34:34,662 DEBUG [com.smartfoxserver.v2.controllers.SystemController-1] binary.BinaryIoHandler     - Binary size: 39
80 00 24 12 00 03 00 01 61 03 03 EC 00 01 63 02         ..$.....a.....c.
00 00 01 70 12 00 02 00 01 72 04 00 00 00 08 00         ...p.....r......
01 75 04 00 00 00 04                                    .u.....         

15:34:34,664 TRACE [pool-1-thread-2] filter.LoggingFilter     - Topic smartfox.USER_LEAVE_ROOM not found, skipping
15:34:34,666 DEBUG [pool-1-thread-2] event.RoomLeaveHandler     - User ( User Name: account-1, Id: 4, Priv: 0, Sess: 192.168.1.33:51711 )  leaving room [ SFSGame: game-1017, Id: 8, Group: default, public: true, minPlayers: 2 ]
In case of logout:

Code: Select all

15:32:32,207 DEBUG [com.smartfoxserver.v2.controllers.SystemController-3] managers.SFSRoomManager     - User: account-1 removed from Room: place-153
15:32:32,207 DEBUG [com.smartfoxserver.v2.controllers.SystemController-3] managers.SFSRoomManager     - User: account-1 removed from Room: game-1014
15:32:32,208 INFO  [com.smartfoxserver.v2.controllers.SystemController-3] entities.SFSZone     - User: account-1 was disconnected.
15:32:32,208 DEBUG [com.smartfoxserver.v2.controllers.SystemController-3] protocol.SFSProtocolCodec     - {OUT}: OnUserLost
15:32:32,209 DEBUG [com.smartfoxserver.v2.controllers.SystemController-3] binary.BinaryIoHandler     - Binary size: 31
80 00 1C 12 00 03 00 01 61 03 03 EA 00 01 63 02         ........a.....c.
00 00 01 70 12 00 01 00 01 75 04 00 00 00 02            ...p.....u..... 

15:32:32,210 DEBUG [com.smartfoxserver.v2.controllers.SystemController-3] protocol.SFSProtocolCodec     - {OUT}: Logout
15:32:32,212 DEBUG [com.smartfoxserver.v2.controllers.SystemController-3] binary.BinaryIoHandler     - Binary size: 38
80 00 23 12 00 03 00 01 61 03 00 02 00 01 63 02         ..#.....a.....c.
00 00 01 70 12 00 01 00 02 7A 6E 08 00 08 4F 6E         ...p.....zn...On
79 78 54 65 73 74                                       yxTest          

15:32:32,213 TRACE [pool-1-thread-2] filter.LoggingFilter     - Topic smartfox.USER_LOGOUT not found, skipping
15:32:32,214 TRACE [pool-1-thread-2] event.UserLogoutEventHandler     - User 1 is logged out
15:32:32,215 INFO  [com.smartfoxserver.v2.controllers.SystemController-3] api.SFSApi     - User logout: ( User Name: account-1, Id: 2, Priv: 0, Sess: 192.168.1.33:51686 ) 
15:32:34,638 DEBUG [pool-2-thread-1] 
Thanks in advance
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Post by Lapo »

It's not a bug, in fact if you check the docs for the LOGOUT event you will notice that the event provides you with all information about the room(s) where the user was joined.
This is much better than firing several separated ROOM events plus a LOGOUT, and there would be more theory behind it... but let's just leave it at that.
Lapo
--
gotoAndPlay()
...addicted to flash games
mente
Posts: 73
Joined: 14 Apr 2011, 14:27

Post by mente »

Excellent, thanks for explaining
Zammy
Posts: 29
Joined: 05 Aug 2014, 16:37

Re: USER_LEAVE_ROOM is not fired on user logout

Post by Zammy »

I am bit confused.

If user disconnects and he is in a room USER_LEAVE_ROOM is not called. Is that correct?
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: USER_LEAVE_ROOM is not fired on user logout

Post by Lapo »

On the server side, yes.
The reason for this is that it would potentially generate a lot of events.

Imagine a User that has joined three Rooms. Instead of receiving a disconnection error + 3 separate events for each Room that was left you just get one event with the details of the user and the list of Rooms he has left.

cheers
Lapo
--
gotoAndPlay()
...addicted to flash games
Post Reply