Example #1
0
        private static void OnReceive(Socket handler)
        {
            if (handler != null)
            {
                try
                {
                    byte[] lenBuf = new byte[4];
                    handler.Receive(lenBuf);

                    int    len = BitConverter.ToInt32(lenBuf, 0);
                    byte[] buf = new byte[len];

                    int trans = 0;
                    while (trans < len)
                    {
                        trans += handler.Receive(buf, trans, len - trans, SocketFlags.None);
                    }

                    if (len > 0)
                    {
                        Image image = ConvertImage(buf);
                        ReceiveImageEventArgs args = new ReceiveImageEventArgs(image);
                        ImageReceived?.Invoke(typeof(ImageServer), args);
                    }
                }
                catch (SocketException e) { }
            }
        }
Example #2
0
 private static void ImageServer_ReceiveImage(object sender, ReceiveImageEventArgs e)
 {
     ImageReceived?.Invoke(typeof(ControllerHost), e);
 }