Two disconnect events are triggered on disconnection

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

Moderators: Lapo, Bax

bearhsu2
Posts: 1
Joined: 08 Mar 2017, 09:42

Two disconnect events are triggered on disconnection

Postby bearhsu2 » 08 Mar 2017, 09:54

I'm using SmartFoxServer 2.12.3. I face an unusual problem when a user disconnects from server.

I registered a handler for disconnect event:

Code: Select all

 this.addEventHandler(SFSEventType.USER_DISCONNECT, UserDisconnectHandler.class);


Also, I make my handler a single instance:

Code: Select all

@Instantiation(InstantiationMode.SINGLE_INSTANCE)
public class UserDisconnectHandler extends BaseServerEventHandler {...


However, when a user disconnects, SOMETIMES two disconnect events are triggered like this in my smartfox.log:
(some info are blurred for privacy)
07 Mar 2017 | 10:29:23,379 | INFO | SFSWorker:Sys:2 | v2.api.SFSApi | | User disconnected: { Zone: MY_ZONE_GAME }, ( User Name: myUser, Id: 83, Priv: 0, Sess: XXX.227.76.115:56511 ) , SessionLen: 49263, Type: JavaScript
07 Mar 2017 | 10:29:23,379 | INFO | SFSWorker:Sys:1 | v2.api.SFSApi | | User disconnected: { Zone: MY_ZONE_GAME }, ( User Name: myUser, Id: 83, Priv: 0, Sess: XXX.227.76.115:56511 ) , SessionLen: 49264, Type: JavaScript


This causes problems because I have some important processes to do in my disconnect handler.
Did I do anything wrong here? Or does anyone have similar experience?

Many thanks.
User avatar
Lapo
Site Admin
Posts: 23027
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Two disconnect events are triggered on disconnection

Postby Lapo » 08 Mar 2017, 15:29

Hi,
do you have a destroy() method in your Extension?
If so make sure that in the first line you have a super.destroy() call, otherwise resources may leak after an Extension restart.

In other words:

Code: Select all

public void destroy()
{
   super.destroy()
   ...
   ... custom code
   ...
}


This is only if you are overriding the method, otherwise, there's no need to add anything.

Cheers
Lapo
--
gotoAndPlay()
...addicted to flash games

Return to “SFS2X Questions”

Who is online

Users browsing this forum: No registered users and 142 guests