Esempio n. 1
0
        private LoginResponse TryToLogin(ServerSideTokenIdentity identity, string username, string password)
        {
            lock (identity)
            {
                if (identity.MatchmakingStatus != UserMatchmakingStatus.NON_LOGGED)
                {
                    return(new LoginResponse
                    {
                        Successfulness = false,
                        Message = "Vec si ulogovan"
                    });
                }

                var user = UserLogic.GetUserByLoginInfo(username, password);

                if (!UserConnectionList.GetInstance().TryToLoginUser(user, identity))
                {
                    return(new LoginResponse
                    {
                        Successfulness = false,
                        Message = "Dati korisnik je vec ulogovan"
                    });
                }

                identity.LastlyFetchedUser = user;
                identity.MatchmakingStatus = UserMatchmakingStatus.LOBBY;

                return(new LoginResponse
                {
                    Successfulness = true,
                    UserInfo = UserLogic.GetUserInfo(user)
                });
            }
        }
        public override void OnUserDisconnect(AsyncUserToken userToken)
        {
            var identity = (ServerSideTokenIdentity)userToken.info;

            ThreadUtils.RepeatingTimeoutLock(
                identity.MatchmakingLock,
                () => ResolveMatchmakingStatusOnQuit(userToken),
                millisecondsTimeOut: 1,
                maxAttempts: 0,
                interAttemptyDelay: 5
                );

            UserConnectionList.GetInstance().LogOutUserUnderIdentity(identity);
            identity.Reset();
            Console.WriteLine("User disconnected");
        }