Esempio n. 1
0
        /*
         * To connect as the client
         */
        private void clientButton_Click(object sender, EventArgs e)
        {
            if (!verifyIPAddress(connectIpBox.Text))
            {
                System.Windows.Forms.MessageBox.Show("Entered IP Adress is not valid !");
                return;
            }

            if(nameBox.Text.Length<2){
                System.Windows.Forms.MessageBox.Show("Please enter a valid name !");
                return;
            }

            //start host.
            Console.WriteLine("Connected!");
            SocketManagement sm = new SocketManagement(connectIpBox.Text, 8000);
            bool hasStarted = sm.startAsClient();

            if (hasStarted) {
                waitLabel.Visible = true;
                hostButton.Enabled = false;
                clientButton.Enabled = false;

                 // Then open the playing window and assign names and signs.

                NetworkPlayForm networkForm = new NetworkPlayForm(setting,sm,nameBox.Text);
                networkForm.Visible = true;
                this.Visible = false;

            }
        }
Esempio n. 2
0
        /*
         * To connect as the client
         */
        private void clientButton_Click(object sender, EventArgs e)
        {
            if (!verifyIPAddress(connectIpBox.Text))
            {
                System.Windows.Forms.MessageBox.Show("Entered IP Adress is not valid !");
                return;
            }

            if (nameBox.Text.Length < 2)
            {
                System.Windows.Forms.MessageBox.Show("Please enter a valid name !");
                return;
            }

            //start host.
            Console.WriteLine("Connected!");
            SocketManagement sm         = new SocketManagement(connectIpBox.Text, 8000);
            bool             hasStarted = sm.startAsClient();

            if (hasStarted)
            {
                waitLabel.Visible    = true;
                hostButton.Enabled   = false;
                clientButton.Enabled = false;

                // Then open the playing window and assign names and signs.


                NetworkPlayForm networkForm = new NetworkPlayForm(setting, sm, nameBox.Text);
                networkForm.Visible = true;
                this.Visible        = false;
            }
        }
Esempio n. 3
0
        private void hostButton_Click(object sender, EventArgs e)
        {
            if (nameBox.Text.Length < 2)
            {
                System.Windows.Forms.MessageBox.Show("Please enter a valid name !");
                return;
            }

            if (ipListBox.SelectedItem == null)
            {
                System.Windows.Forms.MessageBox.Show("Please select an IP Address !");
                return;
            }
            String ip = ipListBox.SelectedItem.ToString();

            if (!verifyIPAddress(ip))
            {
                System.Windows.Forms.MessageBox.Show("Entered IP Adress is not valid !");
                return;
            }

            Console.WriteLine("Hosted!");
            SocketManagement sm         = new SocketManagement(ip, 8000);
            bool             hasStarted = sm.startAsServer();

            if (hasStarted)
            {
                waitLabel.Visible    = true;
                hostButton.Enabled   = false;
                clientButton.Enabled = false;

                NetworkPlayForm networkForm = new NetworkPlayForm(setting, sm, nameBox.Text);
                networkForm.Visible = true;
                this.Visible        = false;
            }
        }
Esempio n. 4
0
        private void hostButton_Click(object sender, EventArgs e)
        {
            if (nameBox.Text.Length < 2)
            {
                System.Windows.Forms.MessageBox.Show("Please enter a valid name !");
                return;
            }

            if (ipListBox.SelectedItem==null)
            {
                System.Windows.Forms.MessageBox.Show("Please select an IP Address !");
                return;
            }
            String ip=ipListBox.SelectedItem.ToString();

            if (!verifyIPAddress(ip))
            {
                System.Windows.Forms.MessageBox.Show("Entered IP Adress is not valid !");
                return;
            }

            Console.WriteLine("Hosted!");
            SocketManagement sm = new SocketManagement(ip, 8000);
            bool hasStarted = sm.startAsServer();

            if(hasStarted){
                waitLabel.Visible = true;
                hostButton.Enabled = false;
                clientButton.Enabled = false;

                NetworkPlayForm networkForm = new NetworkPlayForm(setting,sm,nameBox.Text);
                networkForm.Visible = true;
                this.Visible = false;
            }
        }