Exemple #1
0
        public async void Login()
        {
            Busy = true;

            if (string.IsNullOrEmpty(Email) || string.IsNullOrEmpty(Password))
            {
                LoginFailed?.Invoke(this, "Email and Password are required.");

                Busy = false;

                return;
            }

            var result = await Services.Host.AuthService.Authenticate(Email, Password);

            if (result.Success)
            {
                LoginSuccess?.Invoke(this, EventArgs.Empty);

                Busy = false;

                return;
            }

            LoginFailed?.Invoke(this, result.error_description);

            Busy = false;
        }
        private void LoginButton_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrWhiteSpace(IdText.Text) ||
                string.IsNullOrWhiteSpace(PasswordText.Text))
            {
                MessageBox.Show("누락된 항목이 있습니다.", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            var userList = Globals.UserListSheet.GetUserList().ToList();

            var id = IdText.Text;
            var pw = PasswordText.Text;

            var user = userList
                       .Where(x => x.Id == id)
                       .Where(x => x.Password == pw)
                       .FirstOrDefault();

            if (user != null)
            {
                LoginSuccess?.Invoke(this, user);
            }
            else
            {
                MessageBox.Show("아이디 혹은 비밀번호가 일치하지 않습니다.", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemple #3
0
        public void SetResult(int status)
        {
            Authenticated = status == 0;
            try
            {
                switch (status)
                {
                case LOGIN_SUCCESS:
                    LoginSuccess?.Invoke(this, EventArgs.Empty);
                    return;

                case LOGIN_INVALID:
                    LoginFailed?.Invoke(this, new LoginFailedEventArgs(false));
                    return;

                case LOGIN_BANNED:
                    LoginFailed?.Invoke(this, new LoginFailedEventArgs(true));
                    return;
                }
            }
            finally
            {
                Interlocked.CompareExchange(ref activeAuthRequest, 0, 1);
            }
        }
 private void LoginBtn_Click(object sender, EventArgs e)
 {
     //UserAcount的登录方法 实现登陆
     userAcount = UserAcount.LoginAcount(userTxt.Text.Trim(), pwdTxt.Text.Trim());
     if (userAcount != null)//登录成功
     {
         if (userAcount.accountState == 0)
         {
             MessageBox.Show("密码过期!");
             return;
         }
         if (userAcount.accountState == 2)
         {
             MessageBox.Show("登录失败,用户名或密码错误!");
             return;
         }
         if (userAcount.accountState == 1)
         {
             //登录成功后,用户控件的父级窗体要关闭,显示出主窗体
             //使用事件实现,触发事件
             LoginSuccess?.Invoke(this, null);
         }
     }
     else
     {
         MessageBox.Show("无法登陆,请重试!");
         return;
     }
 }
 public void OnLoginSuccess()
 {
     if (LoginSuccess != null)
     {
         LoginSuccess.Invoke();
         UpdateDisplayName();
     }
 }
Exemple #6
0
 private void LoginSuccessCommand(NetworkMessage message)
 {
     Console.WriteLine("Success!!!");
     if (message.TryGetObject <LoginSuccess>(out LoginSuccess success))
     {
         LoginSuccess?.Invoke(success.Users);
     }
 }
Exemple #7
0
        private void ButtonEnterRoom_OnClick(object sender, RoutedEventArgs e)
        {
            string roomKey = RoomKey.Text.Trim();

            if (CheckRoomKey(roomKey))
            {
                LoginSuccess?.Invoke(roomKey);
            }
        }
 private Task LoggedIn(string message)
 {
     if (debug)
     {
         Console.WriteLine($"OBSERVER: NetworkManagerClient LoggedIn");
     }
     MyData = JsonConvert.DeserializeObject <Player>(message);
     LoginSuccess?.Invoke(this, message);
     return(Task.CompletedTask);
 }
Exemple #9
0
        private async void LoginBtn_Click(object sender, EventArgs e)
        {
            var user = await GetUserAsync(nameBox.Text, passwordBox.Text);

            if (user != null)   // User exists
            {
                LoginSuccess?.Invoke(sender, new UserEventArgs {
                    User = user
                });
            }
        }
Exemple #10
0
 public void SignIn()
 {
     authService.StartSignIn((authId) =>
     {
         HuaweiId = authId;
         LoginSuccess?.Invoke(authId);
     }, (error) =>
     {
         HuaweiId = null;
         LoginFailed?.Invoke(error);
     });
 }
Exemple #11
0
        protected override void HandleAppPacket(AppPacket packet)
        {
            Hexdump(packet.Data);

            switch ((LoginOp)packet.Opcode)
            {
            case LoginOp.ChatMessage:
                Send(AppPacket.Create(LoginOp.Login, new Login(), cryptoBlob));
                break;

            case LoginOp.LoginAccepted:
                if (packet.Data.Length < 80)
                {
                    LoginSuccess?.Invoke(this, false);
                }
                else
                {
                    var dec = Decrypt(packet.Data, 10);
                    var rep = new LoginReply(dec);
                    accountID  = rep.AcctID;
                    sessionKey = rep.Key;
                    LoginSuccess?.Invoke(this, true);
                }
                break;

            case LoginOp.ServerListResponse:
                var header = packet.Get <ServerListHeader>();
                ServerList?.Invoke(this, header.Servers);
                break;

            case LoginOp.PlayEverquestResponse:
                var resp = packet.Get <PlayResponse>();

                if (!resp.Allowed)
                {
                    UnityEngine.Debug.LogError("Response flagged Allowed false");
                    curPlay = null;
                }

                PlaySuccess?.Invoke(this, curPlay);
                break;

            default:
                UnityEngine.Debug.Log($"Unhandled packet in LoginStream: {(LoginOp) packet.Opcode} (0x{packet.Opcode:X04})");
                Hexdump(packet.Data);
                break;
            }
        }
Exemple #12
0
        public void OnEvent(SdkEvent sdkEvent)
        {
            if (sdkEvent.Event.Equals("Connected"))
            {
                Connected?.Invoke(this);
            }
            else if (sdkEvent.Event.Equals("ConnectionFailed"))
            {
                ConnectionFailed?.Invoke(this, sdkEvent.GetEventArgs <ConnectionFailedEventArgs>());
            }
            else if (sdkEvent.Event.Equals("Disconnected"))
            {
                Disconnected?.Invoke(this);
            }
            else if (sdkEvent.Event.Equals("LoginSuccess"))
            {
                LoginSuccess?.Invoke(this, sdkEvent.GetEventArgs <LoginSuccessEventArgs>());
            }
            else if (sdkEvent.Event.Equals("LoginFailed"))
            {
                LoginFailed?.Invoke(this, sdkEvent.GetEventArgs <LoginFailedEventArgs>());
            }
            else if (sdkEvent.Event.Equals("RefreshTokenSuccess"))
            {
                RefreshTokenSuccess?.Invoke(this, sdkEvent.GetEventArgs <RefreshTokenSuccessEventArgs>());
            }
            else if (sdkEvent.Event.Equals("RefreshTokenFailed"))
            {
                RefreshTokenFailed?.Invoke(this, sdkEvent.GetEventArgs <RefreshTokenFailedEventArgs>());
            }
            else if (sdkEvent.Event.Equals("OneTimeKeyGenerated"))
            {
                OneTimeKeyGenerated?.Invoke(this, sdkEvent.GetEventArgs <OneTimeKeyGeneratedEventArgs>());
            }
            else if (sdkEvent.Event.Equals("IncomingCall"))
            {
                var eventArgs = sdkEvent.GetEventArgs <IncomingCallEventArgs>();
                eventArgs.Call = GetIncomingCall(eventArgs.callId);

                IncomingCall?.Invoke(this, eventArgs);
            }
            else
            {
                Debug.LogError($"Unknown Event '{sdkEvent.Event}'");
            }
        }
Exemple #13
0
    public void InitializeGPS()
    {
        PlayGamesClientConfiguration config = new PlayGamesClientConfiguration.Builder()
                                              .RequestEmail()
                                              .Build();

        PlayGamesPlatform.DebugLogEnabled = true;
        PlayGamesPlatform.InitializeInstance(config);
        PlayGamesPlatform.Activate();
        PlayGamesPlatform.Instance.Authenticate(SignInInteractivity.CanPromptAlways, (result) =>
        {
            if (result.Equals(SignInStatus.Success))
            {
                LoginSuccess?.Invoke();
            }
            else
            {
                LoginFailure?.Invoke();
            }
        });
    }
Exemple #14
0
        private void OnLogin(StandardServerLogin packet)
        {
            if (!packet.Success)
            {
                switch (packet.Reason)
                {
                case LoginFailReason.Banned:
                    logger.Error(string.Format("Vous êtes banni jusqu'au {0}. Raison : {1}.", packet.EndSanction, packet.SanctionReason));
                    break;

                case LoginFailReason.InvalidCombinaison:
                    logger.Error("La combinaison utilisateur/mot de passe est invalide.");
                    break;

                case LoginFailReason.UsernameDoesntExist:
                    logger.Error("Le nom d'utilisateur n'existe pas.");
                    break;

                case LoginFailReason.DisabledAccount:
                    logger.Error(string.Format("Votre compte est désactivé. Raison : {0}", packet.SanctionReason));
                    break;

                case LoginFailReason.UserAlreadyConnected:
                    logger.Error("Quelqu'un est déja connecté sur votre compte. Tentez de vous reconnecter maintenant.");
                    break;

                case LoginFailReason.Maintenance:
                    logger.Error("Une maintenance est en cours." + Environment.NewLine + "Raison: " + packet.MaintenanceReason + Environment.NewLine + "Temps estimé: " + packet.MaintenanceTimeEstimation.ToString() + "h.");
                    break;
                }
            }
            else
            {
                LoginSuccess?.Invoke();
            }

            logger.Info(_bot.BotConfig.Username + " connected to the server.");
        }
Exemple #15
0
        private void CustomLoginControl_LoginAttempt(object sender, LoginEventArgs e)
        {
            var user = Users.Where(x => x.CheckLogin(e.Login, e.Password)).SingleOrDefault();

            if (user == null)
            {
                LoginFailed?.Invoke(this, new LoginFailureEventArgs()
                {
                    Errors = new List <LoginFailureEventArgs.LoginError>()
                    {
                        new LoginFailureEventArgs.LoginError()
                        {
                            Field        = LoginFields.All,
                            ErrorMessage = "Wrong username or password"
                        }
                    }
                });
            }
            else
            {
                LoginSuccess?.Invoke(this, EventArgs.Empty);
            }
        }
Exemple #16
0
        private void ThreadLogin()
        {
            // 连接的消息等待
            AwaitToConnect( );

            OperateResult <Socket> connectResult = ConnectServer( );

            if (!connectResult.IsSuccess)
            {
                ConnectFailed( );
                // 连接失败,重新连接服务器
                ThreadPool.QueueUserWorkItem(new WaitCallback(ReconnectServer), null);
                return;
            }

            // 登录成功
            LoginSuccessMethod(connectResult.Content);

            // 登录成功
            LoginSuccess?.Invoke( );
            Interlocked.Exchange(ref isConnecting, 0);
            Thread.Sleep(200);
        }
        private void ThreadLogin()
        {
            lock (lock_connecting)
            {
                if (IsClientConnecting)
                {
                    return;
                }
                IsClientConnecting = true;
            }


            if (ConnectFailedCount == 0)
            {
                // English Version : Connecting Server...
                MessageAlerts?.Invoke("正在连接服务器...");
            }
            else
            {
                int count = 10;
                while (count > 0)
                {
                    if (IsQuie)
                    {
                        return;
                    }
                    // English Version : Disconnected, wait [count--] second to restart
                    MessageAlerts?.Invoke("连接断开,等待" + count-- + "秒后重新连接");
                    Thread.Sleep(1000);
                }
                MessageAlerts?.Invoke("正在尝试第" + ConnectFailedCount + "次连接服务器...");
            }


            stateone.HeartTime = DateTime.Now;
            LogNet?.WriteDebug(ToString( ), "Begin Connect Server, Times: " + ConnectFailedCount);

            OperateResult <Socket> connectResult = CreateSocketAndConnect(EndPointServer, 10000);

            if (!connectResult.IsSuccess)
            {
                ConnectFailedCount++;
                IsClientConnecting = false;
                LoginFailed?.Invoke(ConnectFailedCount);
                LogNet?.WriteDebug(ToString( ), "Connected Failed, Times: " + ConnectFailedCount);
                // 连接失败,重新连接服务器
                ReconnectServer( );
                return;
            }



            // 连接成功,发送数据信息
            OperateResult sendResult = SendStringAndCheckReceive(connectResult.Content, 1, ClientAlias);

            if (!sendResult.IsSuccess)
            {
                ConnectFailedCount++;
                IsClientConnecting = false;
                LogNet?.WriteDebug(ToString( ), "Login Server Failed, Times: " + ConnectFailedCount);
                LoginFailed?.Invoke(ConnectFailedCount);
                // 连接失败,重新连接服务器
                ReconnectServer( );
                return;
            }

            // 登录成功
            ConnectFailedCount  = 0;
            stateone.IpEndPoint = (IPEndPoint)connectResult.Content.RemoteEndPoint;
            stateone.LoginAlias = ClientAlias;
            stateone.WorkSocket = connectResult.Content;
            stateone.WorkSocket.BeginReceive(stateone.BytesHead, stateone.AlreadyReceivedHead,
                                             stateone.BytesHead.Length - stateone.AlreadyReceivedHead, SocketFlags.None,
                                             new AsyncCallback(HeadBytesReceiveCallback), stateone);


            byte[] bytesTemp = new byte[16];
            BitConverter.GetBytes(DateTime.Now.Ticks).CopyTo(bytesTemp, 0);
            SendBytes(stateone, HslProtocol.CommandBytes(HslProtocol.ProtocolCheckSecends, 0, Token, bytesTemp));


            stateone.HeartTime = DateTime.Now;
            IsClientStart      = true;
            LoginSuccess?.Invoke( );
            LogNet?.WriteDebug(ToString( ), "Login Server Success, Times: " + ConnectFailedCount);
            IsClientConnecting = false;
            Thread.Sleep(1000);
        }
Exemple #18
0
 private void OnLoginSuccess()
 {
     LoginSuccess?.Invoke(this, EventArgs.Empty);
 }
Exemple #19
0
 public void OnLoginSuccess() =>
 LoginSuccess?.Invoke(this, EventArgs.Empty);
Exemple #20
0
 private void OnLoginSuccess(AuthorDTO author)
 {
     LoginSuccess?.Invoke(this, author);
 }
Exemple #21
0
 private void NotifyLoggedIn() => LoginSuccess?.Invoke();
 protected virtual void OnLoginSuccess(EventArgs e)
 {
     LoginSuccess?.Invoke(this, e);
 }
Exemple #23
0
 private void OnLoginSuccess(PublisherDTO author)
 {
     LoginSuccess?.Invoke(this, author);
 }
Exemple #24
0
        private void ThreadLogin()
        {
            lock (lock_connecting)
            {
                if (Is_Client_Connecting)
                {
                    return;
                }
                Is_Client_Connecting = true;
            }


            if (Connect_Failed_Count == 0)
            {
                MessageAlerts?.Invoke("正在连接服务器...");
            }
            else
            {
                int count = 10;
                while (count > 0)
                {
                    if (IsQuie)
                    {
                        return;
                    }
                    MessageAlerts?.Invoke("连接断开,等待" + count-- + "秒后重新连接");
                    Thread.Sleep(1000);
                }
                MessageAlerts?.Invoke("正在尝试第" + Connect_Failed_Count + "次连接服务器...");
            }


            stateone.HeartTime = DateTime.Now;
            LogNet?.WriteDebug(LogHeaderText, "Begin Connect Server, Times: " + Connect_Failed_Count);


            OperateResult result = new OperateResult();

            if (!CreateSocketAndConnect(out Socket socket, EndPointServer, result))
            {
                Connect_Failed_Count++;
                Is_Client_Connecting = false;
                LoginFailed?.Invoke(Connect_Failed_Count);
                LogNet?.WriteDebug(LogHeaderText, "Connected Failed, Times: " + Connect_Failed_Count);
                // 连接失败,重新连接服务器
                ReconnectServer();
                return;
            }

            // 连接成功,发送数据信息
            if (!SendStringAndCheckReceive(
                    socket,
                    1,
                    ClientAlias,
                    result
                    ))
            {
                Connect_Failed_Count++;
                Is_Client_Connecting = false;
                LogNet?.WriteDebug(LogHeaderText, "Login Server Failed, Times: " + Connect_Failed_Count);
                LoginFailed?.Invoke(Connect_Failed_Count);
                // 连接失败,重新连接服务器
                ReconnectServer();
                return;
            }

            // 登录成功
            Connect_Failed_Count = 0;
            stateone.IpEndPoint  = (IPEndPoint)socket.RemoteEndPoint;
            stateone.LoginAlias  = ClientAlias;
            stateone.WorkSocket  = socket;
            stateone.WorkSocket.BeginReceive(stateone.BytesHead, stateone.AlreadyReceivedHead,
                                             stateone.BytesHead.Length - stateone.AlreadyReceivedHead, SocketFlags.None,
                                             new AsyncCallback(HeadReceiveCallback), stateone);

            // 发送一条验证消息
            // SendBytes(stateone, CommunicationCode.CommandBytes(CommunicationCode.Hsl_Protocol_Check_Secends));
            byte[] bytesTemp = new byte[16];
            BitConverter.GetBytes(DateTime.Now.Ticks).CopyTo(bytesTemp, 0);
            SendBytes(stateone, NetSupport.CommandBytes(HslProtocol.ProtocolCheckSecends, 0, KeyToken, bytesTemp));


            stateone.HeartTime = DateTime.Now;
            Is_Client_Start    = true;
            LoginSuccess?.Invoke();

            LogNet?.WriteDebug(LogHeaderText, "Login Server Success, Times: " + Connect_Failed_Count);

            Is_Client_Connecting = false;

            Thread.Sleep(1000);
        }
Exemple #25
0
        private async void DoLogin(object passwordBox)
        {
            string password = ((PasswordBox)passwordBox).Password;

            SetDefaultColors();

            if (IsUserDataCorrect(password))
            {
                IsLoading = true;

                Notification = Properties.Resources.LoginNotification;

                // try login
                LoginRegisterResponse response;
                try
                {
                    response = await client.Login(Login, password);
                }
                catch (ConnectionInterruptedException)
                {
                    Notification    = Properties.Resources.ConnectionErrorNotification;
                    isColorsChanged = true;

                    IsLoading = false;
                    return;
                }
                catch (CertificateException)
                {
                    Notification    = Properties.Resources.CertificateErrorNotification;
                    isColorsChanged = true;

                    IsLoading = false;
                    return;
                }

                if (LoginRegisterResponse.Success.Equals(response))
                {
                    IsClosing = true;
                    // wait for animation
                    await System.Threading.Tasks.Task.Run(() => System.Threading.Thread.Sleep(1700));

                    LoginSuccess?.Invoke();
                    Notification = Properties.Resources.WelcomeNotification;
                }
                else if (LoginRegisterResponse.Fail.Equals(response))
                {
                    Notification        = Properties.Resources.LoginErrorNotification;
                    isColorsChanged     = true;
                    IsLoginIncorrect    = true;
                    IsPasswordIncorrect = true;
                }
                else if (LoginRegisterResponse.Error.Equals(response))
                {
                    Notification    = Properties.Resources.UnknownErrorNotification;
                    isColorsChanged = true;
                }
                else if (LoginRegisterResponse.AlreadyLogin.Equals(response))
                {
                    Notification    = Properties.Resources.AlreadyLoginNotification;
                    isColorsChanged = true;
                }

                IsLoading = false;
            }
        }
Exemple #26
0
        private void ClientProc()
        {
            while (isRunning)
            {
                try
                {
                    switch ((Requests)reader.ReadInt32())
                    {
                    case Requests.Message:
                        string fromWho = reader.ReadString();
                        string message = reader.ReadString();
                        MessageReceived?.Invoke(fromWho, message);
                        break;

                    case Requests.PrivateMessage:
                        fromWho = reader.ReadString();
                        message = reader.ReadString();
                        PrivateMessageReceived?.Invoke(fromWho, message);
                        break;

                    case Requests.SystemMessage:
                        message = reader.ReadString();
                        SystemMessageReceived?.Invoke(message);
                        break;

                    case Requests.LoginOK:
                        LoginSuccess?.Invoke();
                        break;

                    case Requests.NickAlreadyTaken:
                        CurrentStatusReceived?.Invoke("This nick is taken");
                        break;

                    case Requests.UserAlreadyOnServer:
                        CurrentStatusReceived?.Invoke("It seems you are already on server");
                        break;

                    case Requests.WrongCredentials:
                        CurrentStatusReceived?.Invoke("Check you nick and password and try again");
                        break;

                    case Requests.UsersListUpdateStart:
                        ReceiveNewUsersList();
                        break;

                    case Requests.StartPrivateChat:
                        string interlocutor = reader.ReadString();
                        OpenPrivateChatForm(interlocutor);
                        break;

                    case Requests.EndPrivateChat:
                        interlocutor = reader.ReadString();
                        ClosePrivateChatForm(interlocutor);
                        break;
                    }
                }
                catch (Exception e)
                {
                    isRunning = false;
                    SystemMessageReceived?.Invoke(e.Message);
                    SystemMessageReceived?.Invoke("Please restart your client");
                }
            }
        }