Page 1 of 1

USER_DISCONNECT fired twice issue

Posted: 07 Aug 2018, 20:21
by moccha
I have setup my AS3 client to fire a single "disconnect" event via the disconnect() command. I've added an event listener server side for the disconnect command, and for some reason it always fires twice server side. Even if I manually close the app, it still runs twice. I added a trace ("Run disconnect") for the event when it's fired.

Image

Here's the server log:

Code: Select all

16:12:27,132 INFO  [SFSWorker:Sys:2] api.SFSApi     - Room joined: [ MMORoom: Lobby, Id: 0, Group: default, AOI: (400, 200, 0) ], { Zone: Rune }, ( User Name: moccha, Id: 0, Priv: 0, Sess: 127.0.0.1:50777 ) , asSpect: false
16:12:31,307 INFO  [SocketReader] sessions.DefaultSessionManager     - Session removed: { Id: 1, Type: DEFAULT, Logged: Yes, IP: 127.0.0.1:50777 }
16:12:31,308 INFO  [SFSWorker:Sys:4] api.SFSApi     - User disconnected: { Zone: Rune }, ( User Name: moccha, Id: 0, Priv: 0, Sess: 127.0.0.1:50777 ) , SessionLen: 4223, Type: Flash
16:12:31,308 INFO  [SFSWorker:Ext:1] Extensions     - {relic}: Run disconnect.
16:12:31,310 INFO  [SFSWorker:Ext:1] Extensions     - {relic}: Run disconnect.


I cannot figure out why this event is fired twice. Does it have to do with catching both the "session removed" and the "User disconnected" actions? I only want to run the disconnect code once, so is there anything I can check to make sure it runs once per user disconnection?

Re: USER_DISCONNECT fired twice issue

Posted: 08 Aug 2018, 08:17
by Lapo
Hi,
make sure you haven't got two instances of the same Extensions running. That's the the likely reason of the issue or, alternatively, you have registered the event handler twice.

Thanks

Re: USER_DISCONNECT fired twice issue

Posted: 08 Aug 2018, 12:11
by moccha
I made sure I didn't register the handler twice, so what should I look for to make sure I don't have the extension running twice? Should I be running the eventHandler somewhere other than init()?

EDIT: I found out that I had called the init function in a way that caused it to be added to the main zone extension. Thank you for your help!