コード例 #1
0
ファイル: Register.cs プロジェクト: davisbd100/ClientePacman
    public Task RegisterPlayer()
    {
        System.Random         generator     = new System.Random();
        UtilitiesHash         utilitiesHash = new UtilitiesHash();
        RegisterServiceClient register;

        register = new RegisterServiceClient(new NetTcpBinding(SecurityMode.None), new EndpointAddress("net.tcp://" + CurrentPlayer.IPDirection + ":8091/RegisterServices"));
        IRegisterServiceJugador player = new IRegisterServiceJugador();

        player.Correo   = Email_InputField.text;
        player.Nombre   = Name_InputField.text;
        player.Username = User_InputField.text;
        player.Password = utilitiesHash.PassHash(Password_InputField.text);
        player.Código   = generator.Next(0, 999999).ToString("D6");

        try
        {
            if (CheckInDb(player))
            {
                switch (register.AddUser(player))
                {
                case DBOperationResultAddResult.Success:
                    SendEmail(player);
                    break;

                case DBOperationResultAddResult.SQLError:
                    throw new TimeoutException();

                case DBOperationResultAddResult.NullObject:
                    throw new SocketException();
                }
            }
        }
        catch (SocketException)
        {
            throw new SocketException();
        }
        catch (TimeoutException)
        {
            throw new TimeoutException();
        }
        catch (DuplicateRecordException)
        {
            throw new DuplicateRecordException();
        }
        CurrentPlayer.Username = player.Username;
        CurrentPlayer.Email    = player.Correo;
        CurrentPlayer.Código   = player.Código;
        return(Task.CompletedTask);
    }
コード例 #2
0
ファイル: Login.cs プロジェクト: davisbd100/ClientePacman
    public Task DoLogin()
    {
        LoginStatus.Status = LoginStatus.EloginStatus.NoLogin;
        UtilitiesHash      utilitiesHash = new UtilitiesHash();
        LoginServiceClient login;

        login = new LoginServiceClient(new NetTcpBinding(SecurityMode.None), new EndpointAddress("net.tcp://" + CurrentPlayer.IPDirection + ":8091/LoginService"));
        ILoginServiceUsuario usuario = new ILoginServiceUsuario();

        usuario.Username = User_InputField.text;
        usuario.Password = utilitiesHash.PassHash(Password_InputField.text);
        Debug.Log(usuario.Password);
        try
        {
            switch (login.ValidateUser(usuario))
            {
            case DBOperationResultAddResult.WrongCredentials:
                LoginStatus.Status = LoginStatus.EloginStatus.WrongCredentials;
                Debug.Log("en los cases");
                break;

            case DBOperationResultAddResult.ConfirmationIsFalse:
                LoginStatus.Status     = LoginStatus.EloginStatus.NotConfirmed;
                CurrentPlayer.Email    = login.GetEmail(usuario);
                CurrentPlayer.Username = usuario.Username;
                Debug.Log(CurrentPlayer.Email);
                break;

            case DBOperationResultAddResult.Success:
                LoginStatus.Status     = LoginStatus.EloginStatus.Succces;
                CurrentPlayer.Username = usuario.Username;
                break;

            case DBOperationResultAddResult.SQLError:
                throw new TimeoutException();

            case DBOperationResultAddResult.NullObject:
                throw new TimeoutException();
            }
        }
        catch (SocketException)
        {
            throw new SocketException();
        }
        catch (TimeoutException)
        {
            throw new TimeoutException();
        }
        return(Task.CompletedTask);
    }