예제 #1
0
        private void btnRegister_Click(object sender, EventArgs e)
        {
            this.accountServer = this.settings["Launcher"]["Accounts"];

            //Lets ping first
            AccountServer.PingRequestStatusCode ping = PingServer(this.settings["Launcher"]["Accounts"]);
            if (ping != AccountServer.PingRequestStatusCode.Ok)
            {
                //Try the backup
                if ((ping = PingServer(this.settings["Launcher"]["AccountsBackup"])) != AccountServer.PingRequestStatusCode.Ok)
                {
                    int num3 = (int)MessageBox.Show("Server error, could not connect. Is your firewall enabled?");
                    return;
                }
                this.accountServer = this.settings["Launcher"]["AccountsBackup"];
            }

            switch (AccountServer.RegisterAccount(new AccountServer.RegisterRequestObject()
            {
                Username = this.txtUsername.Text.Trim(),
                PasswordHash = Md5.Hash(this.txtPassword.Text.Trim()),
                Email = this.txtEmail.Text.Trim()
            }, this.accountServer))

            {
            case AccountServer.RegistrationStatusCode.Ok:
                int num1 = (int)MessageBox.Show("Account created!");
                break;

            case AccountServer.RegistrationStatusCode.MalformedData:
                int num2 = (int)MessageBox.Show("Error: malformed username/password");
                break;

            case AccountServer.RegistrationStatusCode.UsernameTaken:
                int num3 = (int)MessageBox.Show("Username is taken");
                break;

            case AccountServer.RegistrationStatusCode.EmailTaken:
                int num4 = (int)MessageBox.Show("Email is already used");
                break;

            case AccountServer.RegistrationStatusCode.WeakCredentials:
                string msg  = "(too short/invalid characters/invalid email)";
                int    num5 = (int)MessageBox.Show("Credentials are invalid: " + (AccountServer.Reason != null ? AccountServer.Reason : msg));
                break;

            case AccountServer.RegistrationStatusCode.ServerError:
                string defaultMsg = "Server error, could not connect. Is your firewall enabled?";
                int    num6       = (int)MessageBox.Show((AccountServer.Reason != null ? AccountServer.Reason : defaultMsg));
                break;
            }
        }
예제 #2
0
        private void btnPlay_Click(object sender, EventArgs e)
        {
            this.accountServer = this.settings["Launcher"]["Accounts"];
            this.SetCurrentTask("Checking server status...");

            //Lets ping first
            AccountServer.PingRequestStatusCode ping = PingServer(this.settings["Launcher"]["Accounts"]);
            if (ping != AccountServer.PingRequestStatusCode.Ok)
            {
                //Try the backup
                if ((ping = PingServer(this.settings["Launcher"]["AccountsBackup"])) != AccountServer.PingRequestStatusCode.Ok)
                {
                    int num3 = (int)MessageBox.Show("Server error, could not connect. Is your firewall enabled?");
                    return;
                }
                this.accountServer = this.settings["Launcher"]["AccountsBackup"];
            }

            this.SetCurrentTask("Trying credentials...");
            AccountServer.LoginResponseObject payload;
            switch (AccountServer.LoginAccount(new AccountServer.LoginRequestObject()
            {
                Username = this.txtUsername.Text.Trim(),
                PasswordHash = this.txtPassword.Text == "*****" ? this.settings["Credentials"]["Password"] : Md5.Hash(this.txtPassword.Text.Trim())
            }, this.accountServer, out payload))
            {
            case AccountServer.LoginStatusCode.Ok:
                this.LaunchGame(payload.TicketId.ToString(), ((object)payload.Username).ToString());
                break;

            case AccountServer.LoginStatusCode.MalformedData:
                string msg  = "Error: malformed username/password";
                int    num1 = (int)MessageBox.Show((AccountServer.Reason != null ? "Error: " + AccountServer.Reason : msg));
                break;

            case AccountServer.LoginStatusCode.InvalidCredentials:
                int num2 = (int)MessageBox.Show("Invalid username/password");
                break;

            case AccountServer.LoginStatusCode.ServerError:
                int num3 = (int)MessageBox.Show("Server error, could not connect. Is your firewall enabled?");
                break;
            }
        }