USER_DISCONNECT fired twice issue

Post here your questions about the Flash / Flex / Air API for SFS2X

Moderators: Lapo, Bax

User avatar
moccha
Posts: 59
Joined: 13 Feb 2014, 16:09

USER_DISCONNECT fired twice issue

Postby moccha » 07 Aug 2018, 20:21

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?
User avatar
Lapo
Site Admin
Posts: 20426
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: USER_DISCONNECT fired twice issue

Postby Lapo » 08 Aug 2018, 08:17

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
Lapo
--
gotoAndPlay()
...addicted to flash games
User avatar
moccha
Posts: 59
Joined: 13 Feb 2014, 16:09

Re: USER_DISCONNECT fired twice issue

Postby moccha » 08 Aug 2018, 12:11

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!

Return to “SFS2X ActionScript 3 API”

Who is online

Users browsing this forum: No registered users and 1 guest