Пример #1
0
        public void Login(string login, string password)
        {
            if (isWaitingForAuthorizeReply || isAuthorized || !isConnected)
            {
                return;
            }

            isWaitingForAuthorizeReply = true;

            client.Send(new LcRequestLogin(login, HashUtil.HashPassword(password)), Lidgren.Network.NetDeliveryMethod.ReliableOrdered);
        }
        private void WndLoginClient(int id)
        {
            GUILayout.BeginArea(Rect.MinMaxRect(WndInset, 20, LoginWindowSize.x - WndInset, LoginWindowSize.y - WndInset));

            if (!loginClient.isConnected)
            {
                if (GUILayout.Button("Start Login Client"))
                {
                    loginClient.StartLoginClient();
                }
            }
            else
            {
                GUILayout.Label("Connected: " + loginClient.isConnected);
                GUILayout.Label("Authorized: " + loginClient.isAuthorized);
                GUILayout.Label("Session ID: " + loginClient.sessionId);

                GUILayout.Height(15);

                if (showCreateAccount && !loginClient.isWatingForCreateAccountReply && !loginClient.isWaitingForAuthorizeReply)
                {
                    GUILayout.Label("Create new account");
                    GUILayout.Label("Login");
                    login = GUILayout.TextField(login);
                    GUILayout.Label("Password");
                    password = GUILayout.PasswordField(password, '*');
                    GUILayout.Label("Email");
                    email = GUILayout.TextField(email);
                    GUILayout.Label("Promocode");
                    promoCode = GUILayout.TextField(promoCode);

                    GUILayout.Height(15);

                    if (GUILayout.Button("Register"))
                    {
                        loginClient.CreateAccount(login, HashUtil.HashPassword(password), email, promoCode);
                        showCreateAccount = false;

                        login     = "";
                        password  = "";
                        email     = "";
                        promoCode = "";
                    }

                    if (GUILayout.Button("Cancel"))
                    {
                        showCreateAccount = false;
                    }
                }
                else
                if (loginClient.isWaitingForAuthorizeReply)
                {
                    GUILayout.Label("Loggin in ... ");
                    GUILayout.Button("Abort");
                }
                else
                if (!loginClient.isAuthorized)
                {
                    GUILayout.Label("Login");
                    login = GUILayout.TextField(login);
                    GUILayout.Label("Password");
                    password = GUILayout.PasswordField(password, '*');

                    if (GUILayout.Button("Login"))
                    {
                        loginClient.Login(login, password);
                        password = "";
                    }

                    GUILayout.Height(15);

                    if (GUILayout.Button("Register account"))
                    {
                        showCreateAccount = true;
                    }
                }

                if (GUILayout.Button("Stop Login Client"))
                {
                    loginClient.StopLoginClient();
                }
            }

            GUILayout.EndArea();

            GUI.DragWindow(Rect.MinMaxRect(0, 0, 10000, 20));
        }