Пример #1
0
        void ProcessUnprocessedLoginServerResponses()
        {
            List <BasePacket> tempPacketList;

            lock (responsesLock)
            {
                tempPacketList = unprocessedLoginServerResponses;
                unprocessedLoginServerResponses = new List <BasePacket>();
            }

            foreach (BasePacket packet in tempPacketList)
            {
                UserAccountResponse uar = packet as UserAccountResponse;
                if (uar == null)
                {
                    IntrepidSerialize.ReturnToPool(packet);
                    continue;
                }

                //List<PlayerConnectionState> validConnections;
                // the pending users should be a tiny list
                PlayerConnectionState foundPlayer = null;
                int indexOfFoundPlayer            = -1;
                foreach (PlayerConnectionState player in limboConnections)
                {
                    indexOfFoundPlayer++;
                    if (player.tempId == uar.connectionId)
                    {
                        foundPlayer = player;
                        break;
                    }
                }
                if (foundPlayer != null)
                {
                    limboConnections.RemoveAt(indexOfFoundPlayer);
                    foundPlayer.finishedLoginSuccessfully = uar.isValidAccount;
                    if (uar.isValidAccount == false)
                    {
                        invalidPlayers.Add(foundPlayer);
                    }
                    else
                    {
                        loggedInPlayers.Add(foundPlayer);
                    }

                    OnNewPlayerLoggedIn?.Invoke(foundPlayer, uar.isValidAccount, uar.state);
                }
                IntrepidSerialize.ReturnToPool(uar);
            }
        }
Пример #2
0
        void MoveToLoggedInPlayers(List <PlayerConnectionState> tempList)
        {
            for (int i = tempList.Count - 1; i >= 0; --i)
            {
                var player = tempList[i];
                loggedInPlayers.Add(player);
                player.finishedLoginSuccessfully = true;
                tempList.RemoveAt(i);

                PlayerSaveState save = new PlayerSaveState();
                // Fudge the accountId to be the temporary id
                save.accountId = player.tempId;

                OnNewPlayerLoggedIn?.Invoke(player, true, save);
            }
        }