예제 #1
0
        public void Receive()
        {
            Thread ReceiveThr = new Thread(() =>
            {
                try
                {
                    Stream streamReader = ScreeClient.GetStream();
                    string data         = "";
                    while (true)
                    {
                        byte[] byteData = new byte[ScreeClient.ReceiveBufferSize];
                        streamReader.Read(byteData, 0, (int)ScreeClient.ReceiveBufferSize);
                        data = encoding.GetString(byteData);
                        if (data.Contains("DELAY"))
                        {
                            SetDelayTime(data);
                        }
                    }
                }
                catch
                {
                    NotifyMessage.showMessage("Receive was stoped", 2, 1000);
                    BeginConnect();
                }
            });

            ReceiveThr.Start();
        }
예제 #2
0
        public void StartSendImageCapture()
        {
            Thread SendImageCaptureThr = new Thread(() => {
                Stream stream = ScreeClient.GetStream();

                byte[] data;
                try
                {
                    while (true)
                    {
                        data = ScreenManager.GetByteArrayOfScreenCapture(IndexOfscreen);
                        stream.Write(data, 0, data.Length);
                        Thread.Sleep(DelayTimetoCapture);
                    }
                }
                catch
                {
                    //Begin Connect
                    //waiting when client is connected
                    NotifyMessage.showMessage("Send was stoped", 1, 1000);
                }
            });

            SendImageCaptureThr.Start();
        }
예제 #3
0
        private void ShowAppinNotifyIcon()
        {
            this.ShowInTaskbar = false;
            this.Hide();
            notifyIcon.ContextMenu = new ContextMenu();
            notifyIcon.ContextMenu.MenuItems.Add(0, new MenuItem("Exit", new EventHandler(close_btt_Click)));
            NotifyMessage notifyMess = new NotifyMessage(notifyIcon);

            NotifyMessage.showMessage("Screen Client is running", 0, 3000);
        }
예제 #4
0
        public void BeginConnect()
        {
            ScreeClient.Close();
            ScreeClient = new TcpClient();
            IPEndPoint ipEndpoint = new IPEndPoint(IpV4, port);

            int  timeOut = TIMEOUT;
            bool tryConnect;

            while (true)
            {
                if (timeOut <= 0)
                {
                    tryConnect = false;
                    break;
                }

                try
                {
                    ScreeClient.Connect(ipEndpoint);
                    tryConnect = true;
                    break;
                } catch
                {
                    timeOut -= 1000;
                }

                System.Threading.Thread.Sleep(1000);
            }

            if (tryConnect == true)
            {
                SendSomeInfoOfClient(); // send again
                receive = new ReiceveManager();
                send    = new SendManager();
                receive.Receive();
                send.StartSendImageCapture();
                NotifyMessage.showMessage("Screen Client is connect again success", 1, 3000);
            }
            else
            {
                //Exit
                NotifyMessage.showMessage("Screen Client is exitting ...", 2, 3000);
                Environment.Exit(0);
                Application.Exit();
            }
        }