Beispiel #1
0
        private void buttonLogin_Click(object sender, EventArgs e)
        {
            // Disable the login button
            buttonLogin.Enabled = false;
            _pendingLogin = true;

            // Send a packet requesting a login
            var request = new EditorLoginRequestPacket(textUsername.Text, HashHelper.CalculateSha512Hash(textPassword.Text));
            NetworkManager.Instance.SendPacket(request);
        }
        private void LoginHandler(EditorLoginRequestPacket editorLoginRequestPacket)
        {
            var username = editorLoginRequestPacket.Username;
            var password = editorLoginRequestPacket.Password;

            var result = LoginResultPacket.LoginResult.Succesful;

            if (AreCredentialsValid(username, password))
                _authorizationTable.AuthenticateUser(editorLoginRequestPacket.Sender);
            else
                result = LoginResultPacket.LoginResult.Failed;

            var packet = new LoginResultPacket(result);
            ClientNetworkManager.Instance.SendPacket(packet, editorLoginRequestPacket.Sender);
        }
 public static new Packet FromNetBuffer(NetIncomingMessage incomingMessage)
 {
     var packet = new EditorLoginRequestPacket(incomingMessage.ReadString(), incomingMessage.ReadString());
     return packet;
 }