Page 1 of 1

Disconnect vs Logout

Posted: 18 Oct 2010, 09:17
by rparker
Hello,

I was wondering if there was anyway for a server extension to detect the difference between a disconnect and a logout. I know we get an event when a user logs out, but I need to know if they disconnect and not just log out of a zone.

Posted: 18 Oct 2010, 18:43
by BigFIsh
Yes,

You can capture both logout and disconnect internal events.

Disconnect --> http://www.smartfoxserver.com/docs/docPages/serverSideApi/internalEvents/userLost.htm

Logout --> http://www.smartfoxserver.com/docs/docPages/serverSideApi/internalEvents/logOut.html

By the way, only one of these can be triggered for each client. For instance, if the logout internal event was triggered - the disconnect event wont.

Both these internal events can be used in zone and room level extension

Posted: 19 Oct 2010, 01:25
by rparker
So does that mean I choose. If want to listen for disconnect only, that will always work? Meaning, in this case, I don't really care about logout at all, just disconnect.

Posted: 19 Oct 2010, 02:04
by rparker
Just to clarify, if possible I would like to know specifically when a disconnection occurs, planned or unplanned does not matter. I do not want to know when a user has logged out of a zone and has not actually closed the connection to the server.

Posted: 19 Oct 2010, 02:33
by BigFIsh
Sorry if I wasn't clear.

The server dispatch both disconnect (userLost) and logout internal event regardless whether or not you're listening for it.

So, if a user had logged out - the disconnect internal will not be triggered, but the logout internal event will.

And when a user had disconnected, the logout internal event will not be triggered but the disconnect internal event will.

So you should listen for both, and call the same external function from within both internal events.

As a side note, the disconnect internal event may not always be triggered straight away. See --> http://www.smartfoxserver.com/forums/viewtopic.php?t=8272