Пример #1
0
        private void buttonConnect_Click(object sender, EventArgs e)
        {
            //If button clicking will trigger a time-consuming procedure, a thread must be started to handle it.
            //And after openning the thread, no operation depending on the result of the thread running should be included in the function

            m_xmppCH = new XMPPCommandsHandler(this, this.labelSatusSign, this.listBoxEvent);
            Thread connectXMPPThread = new Thread(
                unused => m_xmppCH.Connnect(textBoxUsername.Text, textBoxPassword.Text, textBoxServer.Text, "")
            );
            connectXMPPThread.Start();
        }
Пример #2
0
        public void LoginAndValidate()
        {
            if (!m_isAuthorized)
            {
                int loginStatus = Login();
                if (m_isAuthorized && loginStatus == (int)Status.SUCCESS)
                {
                    //newly authorized account needs validation
                    //Validate require connecting to the xmpp server
                    m_xmppCH = new XMPPCommandsHandler(m_qbClient, m_labelStatus, m_eventList);
                    m_xmppCH.Auth = this;
                    if (m_xmppCH != null && !m_xmppCH.IsOnline)
                    {
                        m_connectXMPPThread = new Thread(
                            unused => m_xmppCH.Connnect("clientdemo", "secret", "yangzi-lius-macbook-pro.local", m_account.Token)
                        );
                        m_connectXMPPThread.Start();
                    }

                    m_validateThread = new Thread(ValidateCompanyMarker);
                    m_validateThread.Start();
                }
                else
                {
                    LogHelper.Debug("Log in failed.");
                    MessageBox.Show("Log in failed.");
                }
            }
            else
            {
                LogHelper.Debug("One user is online. Make it log out if you can.");
                MessageBox.Show("One user is online. Make it log out if you can.");
            }
        }