コード例 #1
0
ファイル: AuthenticationHandler.cs プロジェクト: zarlant/ACE
        private static void AccountSelectCallback(Account account, Session session, PacketInboundLoginRequest loginRequest)
        {
            log.DebugFormat("ConnectRequest TS: {0}", session.Network.ConnectionData.ServerTime);
            var connectRequest = new PacketOutboundConnectRequest(session.Network.ConnectionData.ServerTime, 0, session.Network.ClientId, ISAAC.ServerSeed, ISAAC.ClientSeed);

            session.Network.EnqueueSend(connectRequest);

            if (loginRequest.NetAuthType < NetAuthType.AccountPassword)
            {
                log.Info($"client {loginRequest.Account} connected with no Password or GlsTicket included so booting");

                session.SendCharacterError(CharacterError.AccountInUse);
                session.State = SessionState.NetworkTimeout;

                return;
            }

            if (account == null)
            {
                session.SendCharacterError(CharacterError.AccountDoesntExist);
                session.State = SessionState.NetworkTimeout;
                return;
            }

            if (WorldManager.Find(account.AccountName) != null)
            {
                var foundSession = WorldManager.Find(account.AccountName);

                if (foundSession.State == SessionState.AuthConnected)
                {
                    session.SendCharacterError(CharacterError.AccountInUse);
                    session.State = SessionState.NetworkTimeout;
                }
                return;
            }

            if (loginRequest.NetAuthType == NetAuthType.AccountPassword)
            {
                if (!account.PasswordMatches(loginRequest.Password))
                {
                    log.Info($"client {loginRequest.Account} connected with non matching password does so booting");

                    session.SendCharacterError(CharacterError.AccountInUse);
                    session.State = SessionState.NetworkTimeout;

                    return;
                }

                log.Info($"client {loginRequest.Account} connected with verified password");
            }
            else if (loginRequest.NetAuthType == NetAuthType.GlsTicket)
            {
                log.Info($"client {loginRequest.Account} connected with GlsTicket which is not implemented yet so booting");

                session.SendCharacterError(CharacterError.AccountInUse);
                session.State = SessionState.NetworkTimeout;

                return;
            }

            // TODO: check for account bans

            session.SetAccount(account.AccountId, account.AccountName, (AccessLevel)account.AccessLevel);
            session.State = SessionState.AuthConnectResponse;
        }