コード例 #1
0
        private void Run(string ip, string user, string pass)
        {
            while (_running)
            {
                try
                {
                    var url = GetImageUrl(ip, user, pass);

                    if (!string.IsNullOrEmpty(url))
                    {
                        var image = GetImage(url, user, pass);

                        if (image != null)
                        {
                            OnImageArrived?.Invoke(image);
                        }
                    }
                    else
                    {
                        OnImageArrived.Invoke(null);
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);

                    Task.Delay(SLEEP_TIME).Wait();
                }
            }
        }
コード例 #2
0
        protected override void Execute(QueCmd cmd)
        {
            switch (cmd.cmd_type)
            {
            case QueCmd.QCType.QC_IMAGE_DATA:
            {
                var          buff  = cmd.data as byte[];
                MemoryStream buf   = new MemoryStream(buff);
                Image        image = Image.FromStream(buf, true);
                OnImageArrived?.Invoke(this, image);
                string data2 = "data:image/jpg;base64," + Convert.ToBase64String(buff);
                client_sockets.ForEach(s => s.Send(data2));
            }
            break;

            case QueCmd.QCType.QC_CLINET_OPEN:
            {
                log_.Debug("WebSocket Open");
                client_sockets.Add(cmd.data as IWebSocketConnection);
            }
            break;

            case QueCmd.QCType.QC_CLINET_CLOSE:
            {
                log_.Debug("WebSocket Close");
                client_sockets.Remove(cmd.data as IWebSocketConnection);
            }
            break;

            default:
                break;
            }
        }