public MainWindow()
        {
            InitializeComponent();

            udpProtocol = new UDPProtocol(localPort);
            udpProtocol.UdpSocketReceiveStart(RunCommand);

            ID = Properties.Settings.Default.ID;
            while (ID == 0)
            {
                udpProtocol.UdpSocketSend(udpProtocol.serverIP, udpProtocol.serverPort, new byte[] { 1 });
                Thread.Sleep(5000);
            }

            sendIPPortThread = new Thread(() =>
            {
                while (true)
                {
                    if (ID == 0)
                    {
                        continue;
                    }
                    udpProtocol.UdpSocketSend(udpProtocol.serverIP, udpProtocol.serverPort, new byte[] { 3, (byte)ID });
                    Thread.Sleep(10000);
                }
            });

            viewScreenManager = new ViewScreenManager(ID, controlIP, controlPort, udpProtocol);
            chatWindowManager = new ChatWindowManager(ID, controlIP, controlPort, udpProtocol);

            sendIPPortThread.IsBackground = true;
            sendIPPortThread.Start();
        }
 void GetControlIPPort()
 {
     do
     {
         udpProtocol.UdpSocketSend(udpProtocol.serverIP, udpProtocol.serverPort, new byte[] { 6, 1 });
         Thread.Sleep(5000);
     } while (controlPort == 0);
 }
 private void SendMessage(String message)
 {
     byte[] messagebyte = System.Text.Encoding.UTF8.GetBytes(message);
     byte[] sendbyte    = new byte[messagebyte.Length + 3];
     sendbyte[0] = 8;
     sendbyte[1] = (byte)ID;
     sendbyte[2] = 1;
     sendbyte    = sendbyte.Concat(messagebyte).ToArray();
     udpProtocol.UdpSocketSend(ControlIP, ControlPort, sendbyte);
 }
Example #4
0
        private void SendScreenImage(int x, int y)
        {
            byte[] bx        = BitConverter.GetBytes(x);
            byte[] by        = BitConverter.GetBytes(y);
            byte[] imageData = GetScreenAtPos(x, y);
            byte[] sendData  = new byte[] { 10, (byte)ID, 1 };
            sendData = sendData.Concat(bx).Concat(by).Concat(imageData).ToArray();

            udpProtocol.UdpSocketSend(controlIP, controlPort, sendData);

            //Console.WriteLine("send" + new Random().Next(100));
        }