Inheritance: MonoBehaviour
Example #1
0
        static ManualResetEvent resetEvent;                 // blocking event

        // main
        static void Main(string[] args)
        {
            resetEvent = new ManualResetEvent(false);
            tcpClient c = new tcpClient();

            c.connect("127.0.0.1", 10001);
            resetEvent.WaitOne();                           // Blocks until Set() is called
        }
Example #2
0
        public ConnectedRobot(MainWindow mainWindow, string ip)
        {
            InitializeComponent();

            this.mainWindow = mainWindow;
            controller      = new ControllerController(this);
            hardware        = new Hardware(this);

            settings = new Settings();
            memory   = new MemoryManager(this);

            client = new tcpClient(ip);
            client.connect();

            sensorData = new SensorData(this);
            client.taggedReceivers.Add(sensorData.tag, sensorData.receive);

            controller.startThread();

            Closing += ConnectedRobot_Closing;
        }
Example #3
0
        static void Main(string[] args)
        {
            Console.WriteLine("A iniciar servidor ");

            tcplistener tcplisterner = null;

            tcpClient tcpclient = null;

            networkstream networkstream = null;

            try
            {
                Console.WriteLine(" a aguardar");

                ipendpoint endpoint = new ipendpoint(IPAddress.loopback);

                tcplisterner = new tcplistener(endpoint);

                tcplisterner.start();
                tcpclient = tcplisterner.accepttcpclient();
            }
        }
Example #4
0
        private void button2_Click(object sender, EventArgs e)
        {
            button3.Enabled = true;  //Кнопка добавления заявки в DataGrid на форме
            button2.Enabled = false; //Кнопка отправки сообщения
            button1.Enabled = true;  //Кнопка повторной отправки сообщения

            if ((comboBox1.Text == "") || (comboBox2.Text == "") || (richTextBox1.Text == "") || (richTextBox2.Text == ""))
            {
                if (comboBox1.Text == "")
                {
                    comboBox1.BackColor = Color.LightCoral; button2.Enabled = true; pictureBox1.Visible = true;
                }
                if (comboBox2.Text == "")
                {
                    comboBox2.BackColor = Color.LightCoral; button2.Enabled = true; pictureBox2.Visible = true;
                }
                if (richTextBox1.Text == "")
                {
                    richTextBox1.BackColor = Color.LightCoral; button2.Enabled = true; pictureBox3.Visible = true;
                }
                if (richTextBox2.Text == "")
                {
                    richTextBox2.BackColor = Color.LightCoral; button2.Enabled = true; pictureBox4.Visible = true;
                }

                MessageBox.Show("Проверьте заполнение полей выделенных красным цветом", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                comboBox1.BackColor    = Color.LightGreen;
                comboBox2.BackColor    = Color.LightGreen;
                richTextBox1.BackColor = Color.LightGreen;
                richTextBox2.BackColor = Color.LightGreen;


                int  i     = 0;
                bool iserr = false;

                string lineA  = comboBox1.Text;
                string lineB  = comboBox2.Text;
                string lineC  = richTextBox2.Text;
                string lineD  = richTextBox1.Text;
                string lineId = CreateId();

                try
                {
                    tcpClient client = new tcpClient(lineA, lineB, lineC, lineD, _ip);
                    client.StartClient();
                    otvetClient = client.ansver;
                }
                catch (Exception ex)
                {
                    i++;
                    richTextBox3.BackColor = Color.Red;
                    richTextBox3.Text      = "\r\r\r\r Произошла внутрення систкмная ошибка! \r Просьба обратиться к системному \r Администратору";
                    if (i > 1)
                    {
                        richTextBox1.Text = ex.ToString();
                    }
                    button2.Enabled = true;
                    iserr           = true;
                }

                if (iserr == false)
                {
                    if (otvetClient != "Ok")
                    {
                        richTextBox3.Text = "\r\r\r\r            Повторите отправку. Спасибо.";
                        MessageBox.Show("Произошла системная ошибка. Попробуйте повторить отправку. \r Если ситуация не изменится обратитесь в тех.поддержку.", "Внимание", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        comboBox1.BackColor    = Color.White;
                        comboBox2.BackColor    = Color.White;
                        richTextBox1.BackColor = Color.White;
                        richTextBox2.BackColor = Color.White;
                        button2.Enabled        = true;
                        return;
                    }
                    else
                    {
                        richTextBox3.Text = " Ответ сервера:... " + otvetClient + "\r ------------------------------------------------------" + "\r Заявка отправлена" + "\r ------------------------------------------------------" + "\r Можете закрыть программу";
                    }
                    MessageBox.Show("Заявка отправлена", "Ок", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                    pictureBox1.Visible = false;
                    pictureBox2.Visible = false;
                    pictureBox3.Visible = false;
                    pictureBox4.Visible = false;
                    AddDataTabs(lineA, lineB, lineC, lineId);
                    _count++;
                    label7.Text = Convert.ToString(_count);
                }
                //button1.Enabled = false;
                //comboBox1.Enabled = false;
                //comboBox2.Enabled = false;
                //textBox1.Enabled = false;
            }
        }