Ejemplo n.º 1
0
 protected virtual void OnErrorOccured(NESEventArgs e)
 {
     if (ErrorOccurred != null)
     {
         ErrorOccurred.Invoke(this, e);
         Execution.WaitOne();
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// 触发错误发生事件;
        /// </summary>
        /// <param name="ex"></param>
        protected void RaiseErrorOccurred(Exception ex)
        {
            if (ex == null)
            {
                throw new ArgumentNullException(nameof(ex));
            }

            ErrorOccurred?.Invoke(this, ex);
        }
Ejemplo n.º 3
0
 private void RegisterErrorCallback()
 {
     _errorCallback = (CameraErrorCode error, CameraState current, IntPtr userData) =>
     {
         ErrorOccurred?.Invoke(this, new CameraErrorOccurredEventArgs(error, current));
     };
     CameraErrorFactory.ThrowIfError(Native.SetErrorCallback(_handle, _errorCallback, IntPtr.Zero),
                                     "Setting error callback failed");
 }
Ejemplo n.º 4
0
 /// <summary>
 /// 지정한 클라이언트와의 연결을 해제합니다.
 /// </summary>
 /// <param name="ip">해제할 클라이언트의 IP주소를 지정합니다.</param>
 public void Disconnect(string ip)
 {
     try
     {
         list[ip].Close();
         list.Remove(ip);
     }
     catch { ErrorOccurred?.Invoke(this, new ExceptionEventArgs(new InvalidOperationException("현재 접속 중인 IP주소가 아닙니다."))); }
 }
Ejemplo n.º 5
0
        private void RegisterErrorCallback()
        {
            _errorCallback = (error, current, _) =>
            {
                ErrorOccurred?.Invoke(this, new CameraErrorOccurredEventArgs(error, current));
            };

            Native.SetErrorCallback(_handle, _errorCallback).
            ThrowIfFailed("Setting error callback failed");
        }
Ejemplo n.º 6
0
        private void RegisterErrorCallback()
        {
            _errorOccurredCallback = (error, state, _) =>
            {
                ErrorOccurred?.Invoke(this, new RecordingErrorOccurredEventArgs(error, state));
            };

            Native.SetErrorCallback(_handle, _errorOccurredCallback, IntPtr.Zero).
            ThrowIfError("Failed to initialize ErrorOccurred event");
        }
Ejemplo n.º 7
0
        protected virtual void OnError(Exception error)
        {
#if ANDROID || IOS
            ErrorOccurred?.Invoke(this, new ErrorEventArgs(this, error));
#else
            ErrorOccurred?.Invoke(this, new ErrorEventArgs {
                Error = error
            });
#endif
        }
Ejemplo n.º 8
0
        private void RegisterDataChannelErrorOccurredCallback()
        {
            _webRtcDataChannelErrorOccurredCallback = (dataChannelHandle, error, _) =>
            {
                ErrorOccurred?.Invoke(this, new WebRTCDataChannelErrorOccurredEventArgs((WebRTCError)error));
            };

            NativeDataChannel.SetErrorOccurredCb(_handle, _webRtcDataChannelErrorOccurredCallback).
            ThrowIfFailed("Failed to set data channel error callback.");
        }
Ejemplo n.º 9
0
        async Task DoRecord()
        {
            try
            {
                var frameInterval = TimeSpan.FromSeconds(1.0 / _frameRate);
                _frameCount = 0;

                // Returns false when stopped

                while (_continueCapturing.WaitOne() && !_cancellationToken.IsCancellationRequested)
                {
                    var timestamp = _sw.Elapsed;

                    if (_frameWriteTask != null)
                    {
                        // If false, stop recording
                        if (!await _frameWriteTask)
                        {
                            return;
                        }

                        if (!WriteDuplicateFrame())
                        {
                            return;
                        }
                    }

                    if (_audioWriteTask != null)
                    {
                        await _audioWriteTask;
                    }

                    _frameWriteTask = Task.Run(() => FrameWriter(timestamp));

                    var timeTillNextFrame = timestamp + frameInterval - _sw.Elapsed;

                    if (timeTillNextFrame > TimeSpan.Zero)
                    {
                        Thread.Sleep(timeTillNextFrame);
                    }
                }
            }
            catch (Exception e)
            {
                lock (_syncLock)
                {
                    if (!_disposed)
                    {
                        ErrorOccurred?.Invoke(e);

                        Dispose(false);
                    }
                }
            }
        }
Ejemplo n.º 10
0
 static public void OnError(Exception err)
 {
     Console.WriteLine(err);
     ServiceError = err;
     ServiceErrors.Enqueue(err);
     while (ServiceErrors.Count > 100)
     {
         ServiceErrors.TryDequeue(out _);
     }
     ErrorOccurred?.Invoke(err);
 }
Ejemplo n.º 11
0
        private void RegisterErrorOccurred()
        {
            _errorCb = (errorCode, _) =>
            {
                MediaCodecError error = (Enum.IsDefined(typeof(MediaCodecError), errorCode)) ?
                                        (MediaCodecError)errorCode : MediaCodecError.InternalError;

                ErrorOccurred?.Invoke(this, new MediaCodecErrorOccurredEventArgs(error));
            };
            Native.SetErrorCb(_handle, _errorCb).ThrowIfFailed("Failed to set error callback.");
        }
Ejemplo n.º 12
0
 private void Try(Action action)
 {
     try
     {
         action();
     }
     catch (Exception ex)
     {
         ErrorOccurred?.Invoke(this, new PacketCommunicatorErrorOccurredEventArgs(ex));
     }
 }
Ejemplo n.º 13
0
 internal void SetDefaultSelectedId()
 {
     try
     {
         DefaultSelectedId = Collection.Where(element => element.State == UIElementState.CHECKED).First().Id;
     }
     catch (Exception e)
     {
         ErrorOccurred?.Invoke(Id, e.TargetSite.Name, e.Message);
     }
 }
Ejemplo n.º 14
0
 private void RegisterRecordingErrorOccurredEvent()
 {
     _recorderErrorCallback = (error, currentState, _) =>
     {
         ErrorOccurred?.Invoke(this, new StreamRecorderErrorOccurredEventArgs(
                                   error == StreamRecorderErrorCode.OutOfStorage ?
                                   StreamRecorderError.OutOfStorage : StreamRecorderError.InternalError, currentState));
     };
     Native.SetErrorCallback(_handle, _recorderErrorCallback).
     ThrowIfError("Failed to set error callback");
 }
Ejemplo n.º 15
0
        public async Task <Bucket> GetBucket(string bucketKey)
        {
            client.BaseUrl = new Uri($"https://developer.api.autodesk.com/oss/v2/buckets/{bucketKey}/details");
            request        = new RestRequest(Method.GET);

            request.AddHeader("Authorization", $"Bearer {this.token.AccessToken}").
            AddHeader("Content-Type", "application/json");

            IRestResponse response = await client.ExecuteTaskAsync(request);

            request = null;

            if (response.StatusCode != HttpStatusCode.OK)
            {
                string error = "";
                switch (response.StatusCode)
                {
                case HttpStatusCode.BadRequest:
                    error = "The request could not be understood by the server due to malformed syntax or missing request headers. The client SHOULD NOT repeat the request without modifications. The response body may give an indication of what is wrong with the request.";
                    break;

                case HttpStatusCode.Unauthorized:
                    error = "The supplied authorization header was not valid or the supplied token scope was not acceptable. Verify authentication and try again.The supplied Authorization header was not valid or the supplied token scope was not acceptable. Verify Authentication and try again.";
                    break;

                case HttpStatusCode.Forbidden:
                    error = "The Authorization was successfully validated but permission is not granted. Don’t try again unless you solve permissions first.";
                    break;

                case HttpStatusCode.NotFound:
                    error = "The specified bucket does not exist.";
                    break;

                case HttpStatusCode.InternalServerError:
                    error = "Internal failure while processing the request, reason depends on error.";
                    break;

                default:
                    error = "Unknown error occurred.";
                    break;
                }

                ErrorOccurred?.Invoke(error);
            }

            Dictionary <string, dynamic> data = JsonConvert.DeserializeObject <Dictionary <string, dynamic> >(response.Content);

            Bucket bucket = new Bucket(data["bucketKey"],
                                       data["bucketOwner"],
                                       (long)data["createdDate"],
                                       data["policyKey"]);

            return(bucket);
        }
Ejemplo n.º 16
0
 public void CentralManager_FailedToConnectPeripheral(CBCentralManager central, CBPeripheral peripheral, NSError error)
 {
     Debug.WriteLine("CentralManager_FailedToConnectPeripheral");
     if (_reconnecting)
     {
         Reconnect();
     }
     else
     {
         ErrorOccurred?.Invoke("Unable to connect to board.");
     }
 }
Ejemplo n.º 17
0
        private void RegisterErrorOccurredCallback()
        {
            _webRtcErrorOccurredCallback = (handle, error, state, _) =>
            {
                Log.Info(WebRTCLog.Tag, $"{error}, {state}");

                ErrorOccurred?.Invoke(this, new WebRTCErrorOccurredEventArgs((WebRTCError)error, state));
            };

            NativeWebRTC.SetErrorOccurredCb(Handle, _webRtcErrorOccurredCallback).
            ThrowIfFailed("Failed to set error occurred callback.");
        }
Ejemplo n.º 18
0
 private void SoundOut_Stopped(object sender, PlaybackStoppedEventArgs e)
 {
     CurrentStateChanged();
     if (e.HasError)
     {
         ErrorOccurred?.Invoke(this, new ErrorOccurredEventArgs(e.Exception.Message));
         _fadingService.Cancel();
         StopAndReset();
         _soundOut.Dispose();
         _soundOut = null;
     }
 }
Ejemplo n.º 19
0
        private void RegisterErrorOccurredCallback()
        {
            _playbackErrorCallback = (code, _) =>
            {
                //TODO handle service disconnected error.
                Log.Warn(PlayerLog.Tag, "error code : " + code);
                ErrorOccurred?.Invoke(this, new PlayerErrorOccurredEventArgs((PlayerError)code));
            };

            NativePlayer.SetErrorCb(Handle, _playbackErrorCallback).
            ThrowIfFailed(this, "Failed to set PlaybackError");
        }
Ejemplo n.º 20
0
 private T ExecuteSafe <T>(Func <T> func)
 {
     try
     {
         return(func());
     }
     catch (Exception e)
     {
         ErrorOccurred?.Invoke(this, new ErrorEventArgs(e));
         return(default(T));
     }
 }
Ejemplo n.º 21
0
        public async Task <bool> DeleteBucket(string bucketKey)
        {
            client.BaseUrl = new Uri("https://developer.api.autodesk.com/oss/v2/buckets/" + bucketKey);
            request        = new RestRequest(Method.DELETE);

            request.AddHeader("Authorization", $"Bearer {this.token.AccessToken}");

            IRestResponse response = await client.ExecuteTaskAsync(request);

            request = null;

            if (response.StatusCode != HttpStatusCode.OK)
            {
                string error = "";
                switch (response.StatusCode)
                {
                case HttpStatusCode.BadRequest:
                    error = "The request could not be understood by the server due to malformed syntax or missing request headers. The client SHOULD NOT repeat the request without modifications. The response body may give an indication of what is wrong with the request.";
                    break;

                case HttpStatusCode.Unauthorized:
                    error = "The supplied Authorization header was not valid or the supplied token scope was not acceptable. Verify authentication and try again.";
                    break;

                case HttpStatusCode.Forbidden:
                    error = "The Authorization was successfully validated but permission is not granted. Don’t try again unless you solve permissions first.";
                    break;

                case HttpStatusCode.NotFound:
                    error = "The specified bucket does not exist.";
                    break;

                case HttpStatusCode.Conflict:
                    error = "The bucket is currently marked for deletionThe bucket is currently marked for deletion";
                    break;

                case HttpStatusCode.InternalServerError:
                    error = "Internal failure while processing the request, reason depends on error.";
                    break;

                default:
                    error = "Unknown error occurred.";
                    break;
                }

                ErrorOccurred?.Invoke(error);

                return(false);
            }

            return(true);
        }
Ejemplo n.º 22
0
        public MediaPlayer()
        {
            _player.PlaybackCompleted += (s, e) => Stop();

            _player.BufferingProgressChanged += (s, e) =>
                                                Buffering?.Invoke(this, new BufferingEventArgs(e.Percent));

            _player.ErrorOccurred += (s, e) =>
                                     ErrorOccurred?.Invoke(this, new ErrorEventArgs(e.Error.ToString()));

            _player.SubtitleUpdated += (s, e) =>
                                       SubtitleUpdated?.Invoke(this, new SubtitleUpdatedEventArgs(e.Text, e.Duration));
        }
Ejemplo n.º 23
0
        private void RegisterErrorOccurred()
        {
            _errorCb = (errorCode, _) =>
            {
                MediaCodecError error = (Enum.IsDefined(typeof(MediaCodecError), errorCode)) ?
                                        (MediaCodecError)errorCode : MediaCodecError.InternalError;

                ErrorOccurred?.Invoke(this, new MediaCodecErrorOccurredEventArgs(error));
            };
            int ret = Interop.MediaCodec.SetErrorCb(_handle, _errorCb);

            MultimediaDebug.AssertNoError(ret);
        }
Ejemplo n.º 24
0
    public override async Task StartAsync(CancellationToken cancellationToken)
    {
        try
        {
            string[] devices = WindowsCapture.FindDevices();
            if (devices.Length == 0)
            {
                ErrorOccurred?.Invoke(this, new NotSupportedException("Could not open camera."));
            }

            WindowsCapture.VideoFormat[] formats = WindowsCapture.GetVideoFormat(DefaultCameraId);

            Decoder = new();
            Camera  = new(DefaultCameraId, formats[0]);
Ejemplo n.º 25
0
        public MultiRecorder(params IRecorder[] Recorders)
        {
            if (Recorders == null || Recorders.Length < 2)
            {
                throw new ArgumentException("Atleast two recorders required.", nameof(Recorders));
            }

            _recorders = Recorders;

            foreach (var recorder in Recorders)
            {
                recorder.ErrorOccurred += E => ErrorOccurred?.Invoke(E);
            }
        }
Ejemplo n.º 26
0
 private void OnDisconnected(Session session)
 {
     try
     {
         session.Sended        -= OnSended;
         session.Received      -= OnReceived;
         session.Disconnected  -= OnDisconnected;
         session.ErrorOccurred -= OnErrorOccurred;
         list[session.IP].Dispose();
         list.Remove(session.IP);
         Disconnected?.Invoke(this, new DisconnectEventArgs(session.IP));
     }
     catch (Exception e) { ErrorOccurred?.Invoke(this, new ExceptionEventArgs(e)); }
 }
Ejemplo n.º 27
0
        /// <summary>
        /// Raises the <see cref="ErrorOccurred"/> event, but always returns <see cref="LoggingErrorPolicy.Suppress"/>.
        /// </summary>
        /// <param name="exception">The exception that occurred.</param>
        /// <returns>Returns <see cref="LoggingErrorPolicy.Suppress"/>.</returns>
        public LoggingErrorPolicy ReportError(Exception exception)
        {
            if (exception == null)
            {
                throw new ArgumentNullException(nameof(exception));
            }

#if SUPPORTS_TRACE
            System.Diagnostics.Trace.WriteLine("Logging Error: " + exception.ToString(), "loggingerror");
#endif
            ErrorOccurred?.Invoke(this, new LoggingErrorEventArgs(exception));

            return(LoggingErrorPolicy.Suppress);
        }
Ejemplo n.º 28
0
 internal static void RaiseError(ErrorEventArgs args, string modName)
 {
     /*string errorsSubDirectory = Path.Combine(Settings.ProgramDataPath, ErrorsSubdirectory);
      * if (!string.IsNullOrWhiteSpace(modName))
      *  errorsSubDirectory = Path.Combine(Settings.ModConfigsPath, modName, ErrorsSubdirectory);
      *
      * if (!Directory.Exists(errorsSubDirectory))
      *  Directory.CreateDirectory(errorsSubDirectory);
      *
      * string errorPath = Path.Combine(errorsSubDirectory, GetExceptionFileName());
      * File.WriteAllText(errorPath, args.Title + ErrorSeparator + args.Content);
      * Permissions.GrantAccessFile(errorPath);*/
     ErrorOccurred?.Invoke(null, args);
 }
Ejemplo n.º 29
0
 private void Listen()
 {
     try
     {
         while (serialPort.IsOpen)
         {
             string message = serialPort.ReadLine();
             MessageReceived?.Invoke(this, new MessageReceivedEventArgs(message));
         }
     }
     catch (IOException ex)
     {
         ErrorOccurred?.Invoke(this, new ErrorOccurredEventArgs(ex.Message));
     }
 }
Ejemplo n.º 30
0
        /// <summary>
        /// 서버를 시작합니다.
        /// </summary>
        /// <param name="port">바인딩할 포트 번호를 지정합니다.</param>
        /// <param name="backlog">접속 대기열의 길이를 지정합니다.</param>
        /// <param name="bufferSize">송수신에 사용할 버퍼의 크기를 지정합니다.</param>
        /// <param name="enableMultiBytes">데이터 송수신 시 멀티바이트 수신을 사용할 지 여부를 지정합니다. 멀티바이트 수신 시 데이터 전송 용량에 제한이 없어지지만, 패킷 구조 특성 상, 송수신 측 모두 해당 구현체를 동일하게 사용해야합니다.</param>
        public void Open(int port, int backlog, int bufferSize, bool enableMultiBytes)
        {
            if (!IsActive)
            {
                listener.Connected     += OnConnected;
                listener.ErrorOccurred += OnErrorOccurred;
                listener.Open(port, backlog, bufferSize, enableMultiBytes);

                IsActive = true;
            }
            else
            {
                ErrorOccurred?.Invoke(this, new ExceptionEventArgs(new InvalidOperationException("서버가 이미 동작 중입니다.")));
            }
        }