Esempio n. 1
0
 public void StateChanged(network.ConnectionState newState)
 {
     switch (newState)
     {
     case network.ConnectionState.CONNECTION_LOST:
         MessageBox.Show("Connection to server lost");
         UserClosing = false;
         _dbInterface.UnmarkAsDefault(_account);
         _client.SetListener(null);
         this.Invoke((MethodInvoker) delegate { Close(); });
         break;
     }
 }
Esempio n. 2
0
        public void StateChanged(network.ConnectionState newState)
        {
            switch (newState)
            {
            case network.ConnectionState.CHANNEL_ESTABLISHED:
                if (this.InvokeRequired)
                {
                    this.Invoke((MethodInvoker) delegate { this.updateProgressBar(33, "Connecting to server"); });
                }
                else
                {
                    this.updateProgressBar(33, "Connecting to server");
                }

                _client.Connect();
                break;

            case network.ConnectionState.CHANNEL_FAILED:
                if (this.InvokeRequired)
                {
                    this.Invoke((MethodInvoker) delegate { this.updateProgressBar(0, "Channel establishment failed"); });
                }
                else
                {
                    this.updateProgressBar(0, "Channel establishment failed");
                }

                MessageBox.Show("An error occured while trying to create channel for " + _account.ServerHost + ":" + _account.ServerPort);
                _dbInterface.UnmarkAsDefault(_account);
                if (_client != null)
                {
                    _client.CloseChannel();
                    _client = null;
                }

                if (this.InvokeRequired)
                {
                    this.Invoke((MethodInvoker) delegate { this.LoadingForm_Load(this, null); });
                }
                else
                {
                    LoadingForm_Load(this, null);
                }

                break;

            case network.ConnectionState.CONNECTION_ESTABLISHED:
                if (this.InvokeRequired)
                {
                    this.Invoke((MethodInvoker) delegate { this.updateProgressBar(100, "Connected succesfully"); });
                }
                else
                {
                    this.updateProgressBar(100, "Connected succesfully");
                }

                if (this.InvokeRequired)
                {
                    this.Invoke((MethodInvoker) delegate { showMainForm(); });
                }
                else
                {
                    showMainForm();
                }

                break;

            case network.ConnectionState.CONNECTION_LOST:
                MessageBox.Show("Connection closed by server.Server  " + _account.ServerHost + ":" + _account.ServerPort);
                closeConnection();
                break;

            case network.ConnectionState.CONNECTION_FAILED:
                MessageBox.Show("Connection to server has failed  " + _account.ServerHost + ":" + _account.ServerPort);
                closeConnection();
                break;
            }
        }