This is Konst from Unity forum, i am again with same question.
What i would like is accomplish is to make user1 auto logout and back to login scene if a new user2 logged with same name and password. After i successfully logged i am moving from Scene1 to Scene2.
CombuManager modifyed like so - void AutoPing:
-
void AutoPing ()
-
{
-
{
-
_platform.SetLocalUser(new User());
-
// Notify the user that the account has been logged in from another location
- Application.LoadLevel(Scene1);
-
}
-
});
-
}
so in Scene2 got soft-logout on first AutoPing tick right after scene loaded. But i would like to make it possible only (if) user2 is logged after user1.
I am a noob, please excuse me with such simple questions. Thank you.
I don't understand what means "if user2 is logged after user1", theoretically your code is already doing what you're saying.
FRANCESCO CROCETTI @ SKARED CREATIONS
well i am the user1 is loging... on success load Scene2. Then on first tick of void AutoPing () next code is executed:
-
_platform.SetLocalUser(new User());
- Application.LoadLevel(Scene1);
so user1 going to soft-logout and load back to scene1. But i dont want it in this case because there is no user2 logged yet. I want it only when user2 is logged.
Are you talking about logging 2 users on the same machine (it's not possible currently)? Else I really cannot understand what's your issue (or you're confusing the code), the code in that callback is already being execute when the ping fails and it should definitely fail if the same account has logged in from another PC later (re-read my code, it's executed only when the ping returns FALSE as "success" parameter and if you're currently authenticated, that is exactly the case you keep saying).
FRANCESCO CROCETTI @ SKARED CREATIONS
First of all i am trying to do this on same machine, maybe this is why a have problem.
anyways my apologies for not clear explanations. lets forget about user2 for a moment...
user1 start: scene1 -> login -> success -> scene2 -> void AutoPing() -> execute next code: Ping(true, (bool success) => {
if (!success && localUser.authenticated)
{
_platform.SetLocalUser(new User());
Application.LoadLevel(scene1);
}
});
-> user1 at scene1.
so right after login success i got soft-logout and load scene1.
there is no user2 involved yet at all.
Did you try? If yes then it means you're having issues with "ping" web service because usually it should return TRUE as "success", so enable the flag Debug Log on CombuManager inspector and check what it returns when the ping webservice is called.
FRANCESCO CROCETTI @ SKARED CREATIONS
yep, ti did tried.
if not authenticated...
every ping
on login success it logs once
{"success":true,"message":"{"Id":"3","Username":"ww","GUID":"558036d64bd268.47581676","LastLoginDate":"2015-06-16 14:46:14","LastLoginIp":"67.84.79.89","Email":"","ActivationCode":"","GameCenterId":"","FacebookId":"","ChangePwdCode":"","CustomData":{"Coins":"100","Rank":"1"}}","errors":[]}
then after soft-logout as if not authenticated...
every ping
I tried your code and it worked perfectly as intended: logged in from an instance, then launched a second instance of the app and logged in with the same account, and in the first instance I was correctly logged out. Isn't it what you was expecting?
FRANCESCO CROCETTI @ SKARED CREATIONS
yes this is exactly what i want, but as i told before my first instance(user1) is going to logout right after succeed on login. I am not even try run second instance(user2) to login with in same account because of it. It drives me crazy, must be something i messed up. just cant figure it out.
You shouldn't have calls to ping if you're not authenticated, I don't know what's happening and what is your code so if possible send me the settings to connect to your server by PM so I can make a test myself.
FRANCESCO CROCETTI @ SKARED CREATIONS
YYESSSS!!!! everything working cool now!!! yohhoo! thank you! I appreciate your service very much. just updated my web files with 2.0.2 version files!!!
Have a great Day!
Cool, have fun! 🙂
FRANCESCO CROCETTI @ SKARED CREATIONS