log me out on exit

Post here your questions about Actionscript and Java server side extensions development.

Moderators: Lapo, Bax

alucidworld
Posts: 2
Joined: 26 May 2010, 04:18

log me out on exit

Postby alucidworld » 27 May 2010, 23:22

I'm currently building a game with Unity3D which connects to a SmartFoxPro server. Everything is working perfectly, I'm pulling login credentials from a MySQL database, login works correctly and the game gets setup to play.

My problem is that if I run the game and login to the Smartfox server and then just exit the game, make a change, then try to login again my username is already taken and it won't let me. I have to wait for that session to timeout and it's getting annoying. I tried my own code in the extension to log me out when I'm dropped, but it's not working. Here's the code :

Code: Select all

if (evt.name == "loginRequest")
        {               

} else if (evt.name == "userExit") {
         trace("logout user"+user);
         _server.logoutUser(user)
      } else if (evt.name == "userLost") {
         trace("logout user"+user);
         _server.logoutUser(user);
      }
}


*The user variable is set to the name (in text) of the logged in user. I have trace statements in the AS file (the extension) but nothing comes up in the SFS administrator.
User avatar
BigFIsh
Posts: 1698
Joined: 25 Feb 2008, 19:26
Location: New Zealand

Postby BigFIsh » 28 May 2010, 03:43

You could try force login (fourth parameter in _server.loginUser function) which should automatically disconnect that user if already logged in.

By the way, you can't do _server.logoutUser(user) in userLost internal event. When a userLost event had occured, that user is no longer connected to the server - so there's no sense of trying to log that user out.
Smartfox's forum is my daily newspaper.

Return to “Server Side Extension Development”

Who is online

Users browsing this forum: No registered users and 20 guests