Exemplo n.º 1
0
 private void FormMain_FormClosing(object sender, FormClosingEventArgs e)
 {
     if (serverCom != null)
     {
         serverCom.CloseConnection();
     }
 }
Exemplo n.º 2
0
        private bool Reconnect(string sClientID, string sClientAddr, string sServerAddr, string sBBAddr, string sBBSig)
        {
            allVotersDB            = new VotersDB();
            AllCurrentVoters       = new Voter[0];
            AllCurrentVotersPanels = new Panel[0];
            serverCom = new Communicator();
            string sError;
            bool   bSuccess = serverCom.OpenConnection("reconnectnoname", sClientAddr, sServerAddr, sBBAddr, sBBSig, allVotersDB, out sError);

            if (bSuccess == false)
            {
                serverCom.CloseConnection();
                serverCom = null;
                MessageBox.Show("Could not connect to server! " + sError, "Fatal Error");
                return(false);
            }
            bSuccess = serverCom.Reconnect(Int32.Parse(sClientID), out sError);
            if (bSuccess == false)
            {
                serverCom.CloseConnection();
                serverCom = null;
                MessageBox.Show("Could not reconnect the client! " + sError, "Fatal Error");
                return(false);
            }

            m_bIsLogIn = true;
            m_LoginForm.Close();
            MessageBox.Show("Press OK only when all voters were added to the server. The client will receive its voter list on pressing OK.", "Voter List Update");

            if (false == serverCom.GetVoterListFromServer(out sError))
            {
                serverCom.CloseConnection();
                serverCom = null;
                MessageBox.Show("Failed getting voters from server. exiting. " + sError, "Fatal Error");
                return(false);
            }
            return(true);
        }