Ejemplo n.º 1
0
 void _Server_DisconnectEvent(Secure_Stream client)
 {
     if (_Server.ClientCount <= 0)
     {
         _Desktop_Service.Capturing = false;//stop capturing since no clients are connected
     }
 }
Ejemplo n.º 2
0
        void _Server_NewClientEvent(Secure_Stream client)
        {
            if (!_Desktop_Service.Capturing)
            {
                _Desktop_Service.Capturing = true;
                Thread.Sleep(200);//make sure to sleep long enough for the background service to start up and get an image if needed.
            }
            var ms  = new Tcp_Message((int)Desktop_Sharing_Shared.Message_Types.RESOLUTION_CHANGE);
            var tmp = _Desktop_Service._LastImage;//make sure to get a copy

            ms.Add_Block(BitConverter.GetBytes(tmp.Dimensions.Height));
            ms.Add_Block(BitConverter.GetBytes(tmp.Dimensions.Width));

            byte[] imgbytes;
            using (var msout = new MemoryStream())
            {
                unsafe
                {
                    fixed(byte *datb = tmp.Data)
                    {
                        using (Bitmap image = new Bitmap(tmp.Dimensions.Width, tmp.Dimensions.Height, tmp.Dimensions.Width * 4, PixelFormat.Format32bppRgb, new IntPtr(datb)))
                        {
                            image.Save(msout, ImageFormat.Png);
                            imgbytes = msout.ToArray();
                        }
                    }
                }
            }
            ms.Add_Block(imgbytes);
            client.Encrypt_And_Send(ms);
        }