Esempio n. 1
0
        private void HandleLogin(int index, byte[] data)
        {
            Console.WriteLine(@"Received login packet");
            var buffer = new PacketBuffer();

            buffer.AddBytes(data);
            buffer.GetInteger();
            var username = buffer.GetString();
            var password = buffer.GetString();

            if (!_userService.AccountExists(username))
            {
                SendMessage(index, "Username does not exist!", Warning);
                return;
            }

            if (!_userService.PasswordOK(username, password))
            {
                SendMessage(index, "Password incorrect!", Warning);
                return;
            }

            var player = _userService.LoadPlayer(username);

            Types.PlayerIds[index] = player.Id;
            _userService.ActiveUsers.Add(player);
            ServerTCP.tempPlayer[index].inGame = true;
            XFerLoad(index);
            SendGalaxy(index);
            SendItems(index);
            SendNebulae(index);
            SendMessage(-1, player.Name + " has connected.", Notification);
            Globals.FullData = true;
            Console.WriteLine(username + @" logged in successfully.");
            ServerTCP.tempPlayer[index].receiving = true;
        }