Exemplo n.º 1
0
        private static void Bw_DoWork(object sender, DoWorkEventArgs e)
        {
            IPAddress   localAddr = IPAddress.Parse(GetLocalIPAddress());
            int         port      = 12345;
            TcpListener server    = new TcpListener(localAddr, port);

            server.Start();
            while (true)
            {
                Console.WriteLine("Ожидание подключений... ");

                TcpClient client = server.AcceptTcpClient();
                Console.WriteLine("Подключен клиент. Выполнение запроса...");
                using (NetworkStream stream = client.GetStream())
                {
                    byte[] data = new byte[1024];
                    using (MemoryStream ms = new MemoryStream())
                    {
                        int numBytesRead;
                        while ((numBytesRead = stream.Read(data, 0, data.Length)) > 0)
                        {
                            ms.Write(data, 0, numBytesRead);
                        }
                        byte[] result           = ms.ToArray();
                        DesktopImageCommand cmd = ScreenCastingCommand.GetCommand(result) as DesktopImageCommand;
                        bw.ReportProgress(0, cmd.Image);
                        Console.WriteLine("Image set");
                    }
                }
            }
        }
Exemplo n.º 2
0
        static void timerCallback(object o)
        {
            DesktopImageCommand cmd = new DesktopImageCommand();

            cmd.Image = screenCapture.CaptureScreen();
            byte[] data = ScreenCastingCommand.Transform(cmd);

            client = new TcpClient();
            client.Connect(ip, port);
            client.GetStream().Write(data, 0, data.Length);
            client.GetStream().Close();
        }