Пример #1
0
        private void register_worker_DoWork(object sender, DoWorkEventArgs e)
        {
            IKdcService proxy           = KdcProxy.Instance.GetProxy();
            string      usernameInvoked = string.Empty;
            string      passwordInvoked = string.Empty;

            Dispatcher.BeginInvoke(new Action(delegate
            {
                usernameInvoked = txtUserName.Text;
                passwordInvoked = txtPassWord.Password.ToString();
            }));


            Thread.Sleep(100);

            /*User user = proxy.RegisterApp(usernameInvoked, passwordInvoked);
             *
             * if (user == null)
             * {
             *  ClientAllData.Instance.setMyClient(null);
             * }
             *
             * else
             * {
             *  ClientAllData.Instance.setMyClient(user);
             * }*/
        }
Пример #2
0
        public MainWin()
        {
            InitializeComponent();

            getSessionKeyForChatWorker.DoWork             += getSessionKeyWorker_DoWork;
            getSessionKeyForChatWorker.RunWorkerCompleted += getSessionKeyWorker_RunWorkerCompleted;

            getSessionKeyForFtpWorker.DoWork += getSessionKeyForFtpWorker_DoWork;

            ClientKdcCallBack.Instance.newConnectedUserEvnt += (sender, message_contant) =>
            {
                Dispatcher.Invoke(() => addUserToPartnerUsers(message_contant));
            };

            ClientKdcCallBack.Instance.openChatWindowEvnt += (sender, userPort) =>
            {
                Dispatcher.Invoke(() => openChatWindow(userPort));
            };


            kdcProxy = KdcProxy.Instance.GetProxy();
            List <string> allUsers = kdcProxy.getAllConnectedUsers();

            allUsers.Remove(ClientAllData.Instance.getMyUsername());
            addUserToPartnerUsers(allUsers);

            ftpProxy = FtpProxy.Instance.GetFtpProxy();

            ClientFtpCallBack.Instance.finishRequstConnectionProcessEvent += (sender, finishedProcess) =>
            {
                Dispatcher.Invoke(() => finishRequstConnectionProcessUI(finishedProcess));
            };
        }
Пример #3
0
 private KdcProxy()
 {
     // creat a channel to comunicate with the game server
     channel = new DuplexChannelFactory <IKdcService>(ClientKdcCallBack.Instance, "KdcServiceEndpoint");
     proxy   = channel.CreateChannel();
 }
Пример #4
0
        private void login_worker_DoWork(object sender, DoWorkEventArgs e)
        {
            bool        looginSuccess   = false;
            IKdcService proxy           = KdcProxy.Instance.GetProxy();
            string      usernameInvoked = string.Empty;
            string      passwordInvoked = string.Empty;

            Dispatcher.BeginInvoke(new Action(delegate
            {
                usernameInvoked = txtUserName.Text;
                passwordInvoked = txtPassWord.Password.ToString();
            }));


            Thread.Sleep(100);
            // try to log in to the server
            ClientAllData.Instance.setMyUsername(usernameInvoked);
            CKdcToClientLogInData logginData = proxy.LogInApp(usernameInvoked);

            // parse the result
            if (logginData != null)
            {
                string passWordHash = string.Empty;
                using (MD5 md5Hash = MD5.Create())
                {
                    passWordHash = CMd5hash.GetMd5Hash(md5Hash, passwordInvoked);
                }

                string retDecUserName = CAes.SimpleDecryptWithPassword(logginData.m_username, passWordHash);
                byte[] retDecPassword = CAes.SimpleDecryptWithPassword(logginData.m_kdcAsSessionKey, passWordHash);
                byte[] localPortByte  = CAes.SimpleDecryptWithPassword(logginData.m_localPort, passWordHash);
                int    localPort      = BitConverter.ToInt32(localPortByte, 0);

                if (retDecUserName == usernameInvoked)
                {
                    string retChallenge = CAes.SimpleDecryptWithPassword(logginData.m_challenge, passWordHash);

                    CLogInStatus logginStatus = new CLogInStatus();
                    logginStatus.m_username  = retDecUserName;
                    logginStatus.m_logInFail = false;
                    logginStatus.m_challenge = CAes.SimpleEncrypt(retChallenge + retChallenge, retDecPassword, retDecPassword);
                    if (proxy.SetLoginStatus(logginStatus))
                    {
                        clientPrivateData myClient = ClientAllData.Instance.getMyClient();
                        myClient.username          = retDecUserName;
                        myClient.m_kdcAsSessionKey = retDecPassword;
                        myClient.m_loginSucccess   = true;
                        myClient.m_localPort       = localPort;
                        looginSuccess = true;
                    }
                }
            }

            if (!looginSuccess)
            {
                CLogInStatus logginStatus = new CLogInStatus();
                logginStatus.m_username  = usernameInvoked;
                logginStatus.m_logInFail = true;
                proxy.SetLoginStatus(logginStatus);
            }
        }