Exemple #1
0
        private void OnRead(IAsyncResult result)
        {
            Application.Current.Dispatcher.Invoke(new Action(() =>
            {
                try
                {
                    if (!port.IsOpen)
                    {
                        return;
                    }

                    int numRead = port.BaseStream.EndRead(result);

                    if (numRead > 0)
                    {
                        OnDataReceived(Encoding.ASCII.GetString(byteBuffer, 0, numRead));
                    }
                }
                catch (Exception ex)
                {
                    ErrorReceived?.Invoke("OnRead");
                    Console.WriteLine($"Не удалось получить ответ от {port.PortName}.\n{ex.Message}");
                }
            }));
            ReadAsync();
        }
Exemple #2
0
        private void VoiceWebSocket_OnClose(object sender, EventArgs e)
        {
            VoiceDebugLogger.Log($"VoiceWebSocket was closed.", MessageLevel.Critical);
            ErrorReceived?.Invoke(this, new EventArgs());

            Dispose();
        }
Exemple #3
0
 private void port_ErrorReceived(object sender, SerialErrorReceivedEventArgs e)
 {
     if (!pendingClose[((SerialPort)sender).PortName])
     {
         ErrorReceived.Rise(sender, new SerialPortErrorEventArgs(((SerialPort)sender).PortName, e.EventType));
     }
 }
Exemple #4
0
        public EmbedIOAuthServer(Uri baseUri, int port, Assembly resourceAssembly, string resourcePath)
        {
            Ensure.ArgumentNotNull(baseUri, nameof(baseUri));

            BaseUri = baseUri;
            Port    = port;

            _webServer = new WebServer(port)
                         .WithModule(new ActionModule("/", HttpVerbs.Post, (ctx) =>
            {
                var query = ctx.Request.QueryString;
                var error = query["error"];
                if (error != null)
                {
                    ErrorReceived?.Invoke(this, error, query["state"]);
                    throw new AuthException(error, query["state"]);
                }

                var requestType = query.Get("request_type");
                if (requestType == "token")
                {
                    ImplictGrantReceived?.Invoke(this, new ImplictGrantResponse(
                                                     query["access_token"] !, query["token_type"] !, int.Parse(query["expires_in"] !)
                                                     )
                    {
                        State = query["state"]
                    });
Exemple #5
0
        public async Task <bool> LaunchGameAsync(LaunchProfile profile, Version version)
        {
            var startInfo = new ProcessStartInfo
            {
                FileName               = profile.IsDebugMode ? _gamePathService.JavaPath : _gamePathService.JavawPath,
                WorkingDirectory       = _gamePathService.WorkingDir,
                Arguments              = BuildArguments(profile, version),
                UseShellExecute        = profile.IsDebugMode,
                RedirectStandardOutput = !profile.IsDebugMode,
                RedirectStandardError  = !profile.IsDebugMode,
            };

            _gameProcess = Process.Start(startInfo);

            _gameProcess.EnableRaisingEvents = true;
            _gameProcess.Exited += (s, e) => Exited?.Invoke(_gameProcess.ExitCode);

            if (!profile.IsDebugMode)
            {
                _gameProcess.ErrorDataReceived += (s, e) => ErrorReceived?.Invoke(e.Data);
                _gameProcess.BeginErrorReadLine();

                _gameProcess.OutputDataReceived += (s, e) => LogReceived?.Invoke(e.Data);
                _gameProcess.BeginOutputReadLine();

                if (!_gameProcess.HasExited)
                {
                    await Task.Run(() => _gameProcess.WaitForInputIdle());
                }
            }

            return(!_gameProcess.HasExited);
        }
        public async Task RequestDeviceList()
        {
            var resp = await SendMessage(new RequestDeviceList(nextMsgId));

            if (!(resp is DeviceList) || (resp as DeviceList).Devices == null)
            {
                if (resp is Error)
                {
                    _owningDispatcher.Invoke(() =>
                    {
                        ErrorReceived?.Invoke(this, new ErrorEventArgs(resp as Error));
                    });
                }

                return;
            }

            foreach (var d in (resp as DeviceList).Devices)
            {
                if (!_devices.ContainsKey(d.DeviceIndex))
                {
                    var device = new ButtplugClientDevice(d);
                    if (_devices.TryAdd(d.DeviceIndex, device))
                    {
                        _owningDispatcher.Invoke(() =>
                        {
                            DeviceAdded?.Invoke(this, new DeviceEventArgs(device, DeviceAction.ADDED));
                        });
                    }
                }
            }
        }
Exemple #7
0
 private void Channel_UnsolicitedEvent(object sender, UnsolicitedEventArgs e)
 {
     if (e.Line1 == "RING")
     {
         IncomingCall?.Invoke(this, new IncomingCallEventArgs());
     }
     else if (e.Line1.StartsWith("VOICE CALL: BEGIN"))
     {
         CallStarted?.Invoke(this, new CallStartedEventArgs());
     }
     else if (e.Line1.StartsWith("VOICE CALL: END"))
     {
         CallEnded?.Invoke(this, CallEndedEventArgs.CreateFromResponse(e.Line1));
     }
     else if (e.Line1.StartsWith("MISSED_CALL: "))
     {
         MissedCall?.Invoke(this, MissedCallEventArgs.CreateFromResponse(e.Line1));
     }
     else if (e.Line1.StartsWith("+CMTI: "))
     {
         SmsReceived?.Invoke(this, SmsReceivedEventArgs.CreateFromResponse(e.Line1));
     }
     else if (e.Line1.StartsWith("+CUSD: "))
     {
         UssdResponseReceived?.Invoke(this, UssdResponseEventArgs.CreateFromResponse(e.Line1));
     }
     else if (e.Line1.StartsWith("+CME ERROR:"))
     {
         ErrorReceived?.Invoke(this, ErrorEventArgs.CreateFromCmeResponse(e.Line1));
     }
     else if (e.Line1.StartsWith("+CMS ERROR:"))
     {
         ErrorReceived?.Invoke(this, ErrorEventArgs.CreateFromCmsResponse(e.Line1));
     }
 }
Exemple #8
0
#pragma warning restore 4014

        private void VoiceWebSocket_OnError(object sender, EventArgs e)
        {
            VoiceDebugLogger.Log("Error in VoiceWebSocket.", MessageLevel.Critical);
            ErrorReceived?.Invoke(this, new EventArgs());

            //Won't worror about on error for now
        }
Exemple #9
0
 private void port_ErrorReceived(object sender, SerialErrorReceivedEventArgs e)
 {
     if (!pendingClose)
     {
         ErrorReceived.Rise(this, e);
     }
 }
Exemple #10
0
        private void OnError(Jid about, Error error)
        {
            var attribute = error.GetAttribute("type");
            var tagName   = error.FirstChild.TagName;
            var errorText = error.ErrorText;

            ErrorReceived?.Invoke(this, new ErrorReceivedEventArgs(about, attribute, tagName, errorText));
        }
Exemple #11
0
        /// <summary>
        /// Message Received event handler. Either tries to match incoming messages as replies to
        /// messages we've sent, or fires an event related to an incoming event, like device
        /// additions/removals, log messages, etc.
        /// </summary>
        /// <param name="aSender">Object sending the open event, unused.</param>
        /// <param name="aArgs">Event parameters, including the data received.</param>
        private async void MessageReceivedHandler(object aSender, MessageReceivedEventArgs aArgs)
        {
            var msg = aArgs.Message;

            switch (msg)
            {
            case Log l:
                Log?.Invoke(this, new LogEventArgs(l));
                break;

            case DeviceAdded d:
                var dev = new ButtplugClientDevice(_bpLogManager, this, SendDeviceMessageAsync, d);
                _devices.Add(d.DeviceIndex, dev);
                DeviceAdded?.Invoke(this, new DeviceAddedEventArgs(dev));
                break;

            case DeviceRemoved d:
                if (!_devices.ContainsKey(d.DeviceIndex))
                {
                    ErrorReceived?.Invoke(this,
                                          new ButtplugExceptionEventArgs(
                                              new ButtplugDeviceException(_bpLogger,
                                                                          "Got device removed message for unknown device.",
                                                                          msg.Id)));
                    return;
                }

                var oldDev = _devices[d.DeviceIndex];
                _devices.Remove(d.DeviceIndex);
                DeviceRemoved?.Invoke(this, new DeviceRemovedEventArgs(oldDev));
                break;

            case ScanningFinished _:
                // The scanning finished event is self explanatory and doesn't require extra arguments.
                ScanningFinished?.Invoke(this, new EventArgs());
                break;

            case Error e:
                // This will both log the error and fire it from our ErrorReceived event handler.
                ErrorReceived?.Invoke(this, new ButtplugExceptionEventArgs(ButtplugException.FromError(_bpLogger, e)));

                if (e.ErrorCode == Error.ErrorClass.ERROR_PING)
                {
                    PingTimeout?.Invoke(this, EventArgs.Empty);
                    await DisconnectAsync().ConfigureAwait(false);
                }

                break;

            default:
                ErrorReceived?.Invoke(this,
                                      new ButtplugExceptionEventArgs(
                                          new ButtplugMessageException(_bpLogger,
                                                                       $"Got unhandled message: {msg}",
                                                                       msg.Id)));
                break;
            }
        }
        public void Open(UsbManager usbManager, int bufferSize = DEFAULT_BUFFERSIZE)
        {
            if (disposed)
            {
                throw new ObjectDisposedException(GetType().Name);
            }
            if (IsOpen)
            {
                throw new InvalidOperationException();
            }

            var connection = usbManager.OpenDevice(port.GetDriver().GetDevice());

            if (connection == null)
            {
                throw new Java.IO.IOException("Failed to open device");
            }
            isOpen = true;

            buffer = new byte[bufferSize];
            port.Open(connection);
            port.SetParameters(BaudRate, DataBits, StopBits, Parity);

            cancelationTokenSource = new CancellationTokenSource();
            var cancelationToken = cancelationTokenSource.Token;

            cancelationToken.Register(() => Log.Info(TAG, "Cancellation Requested"));

            Task.Run(() => {
                Log.Info(TAG, "Task Started!");
                try
                {
                    while (true)
                    {
                        cancelationToken.ThrowIfCancellationRequested();

                        Step(); // execute step
                    }
                }
                catch (OperationCanceledException)
                {
                    throw;
                }
                catch (Exception e)
                {
                    Log.Warn(TAG, "Task ending due to exception: " + e.Message, e);
                    ErrorReceived.Raise(this, new UnhandledExceptionEventArgs(e, false));
                }
                finally
                {
                    port.Close();
                    port.Driver.Device.Dispose();//richard: avoid GREF leak
                    buffer = null;
                    isOpen = false;
                    Log.Info(TAG, "Task Ended!");
                }
            }, cancelationToken);
        }
        /// <summary>
        /// Websocket Message Received event handler. Either tries to match incoming messages as
        /// replies to messages we've sent, or fires an event related to an incoming event, like
        /// device additions/removals, log messages, etc.
        /// </summary>
        /// <param name="aSender">Object sending the open event, unused.</param>
        /// <param name="aArgs">Event parameters, including the data received.</param>
        private void MessageReceivedHandler(object aSender, WebSocket4Net.MessageReceivedEventArgs aArgs)
        {
            var msgs = Deserialize(aArgs.Message);

            foreach (var msg in msgs)
            {
                if (msg.Id > 0 && _waitingMsgs.TryRemove(msg.Id, out TaskCompletionSource <ButtplugMessage> queued))
                {
                    queued.TrySetResult(msg);
                    continue;
                }

                switch (msg)
                {
                case Log l:
                    _owningDispatcher.Send(_ =>
                    {
                        Log?.Invoke(this, new LogEventArgs(l));
                    }, null);
                    break;

                case DeviceAdded d:
                    var dev = new ButtplugClientDevice(d);
                    _devices.AddOrUpdate(d.DeviceIndex, dev, (idx, old) => dev);
                    _owningDispatcher.Send(_ =>
                    {
                        DeviceAdded?.Invoke(this, new DeviceEventArgs(dev, DeviceEventArgs.DeviceAction.ADDED));
                    }, null);
                    break;

                case DeviceRemoved d:
                    if (_devices.TryRemove(d.DeviceIndex, out ButtplugClientDevice oldDev))
                    {
                        _owningDispatcher.Send(_ =>
                        {
                            DeviceRemoved?.Invoke(this, new DeviceEventArgs(oldDev, DeviceEventArgs.DeviceAction.REMOVED));
                        }, null);
                    }

                    break;

                case ScanningFinished sf:
                    _owningDispatcher.Send(_ =>
                    {
                        ScanningFinished?.Invoke(this, new ScanningFinishedEventArgs(sf));
                    }, null);
                    break;

                case Error e:
                    _owningDispatcher.Send(_ =>
                    {
                        ErrorReceived?.Invoke(this, new ErrorEventArgs(e));
                    }, null);
                    break;
                }
            }
        }
Exemple #14
0
        internal void OnMessage(Guid clientId, MessageContainer container)
        {
            if (!_connections.TryGetValue(clientId, out WsConnection connection))
            {
                return;
            }

            switch (container.Identifier)
            {
            case nameof(ConnectionRequest):
                var connectionRequest  = ((JObject)container.Payload).ToObject(typeof(ConnectionRequest)) as ConnectionRequest;
                var connectionResponse = new ConnectionResponse
                {
                    Result    = ResultCode.Ok,
                    IsSuccess = true,
                };
                if (_connections.Values.Any(c => c.Username == connectionRequest.Username))
                {
                    string reason = $"User '{connectionRequest.Username}' is already logged in.";
                    connectionResponse.Result    = ResultCode.Failure;
                    connectionResponse.IsSuccess = false;
                    connectionResponse.Reason    = reason;
                    connection.Send(connectionResponse.GetContainer());
                    ErrorReceived?.Invoke(this, new ErrorReceivedEventArgs(reason, DateTime.Now));
                }
                else
                {
                    connection.Username            = connectionRequest.Username;
                    connectionResponse.ActiveUsers = _connections.Where(c => c.Value.Username != null).Select(u => u.Value.Username).ToList();
                    connection.Send(connectionResponse.GetContainer());
                    ConnectionStateChanged?.Invoke(this, new ConnectionStateChangedEventArgs(connection.Username, true, DateTime.Now));
                    ConnectionReceived?.Invoke(this, new ConnectionReceivedEventArgs(connection.Username, true, DateTime.Now));
                }
                break;

            case nameof(MessageRequest):
                var messageRequest = ((JObject)container.Payload).ToObject(typeof(MessageRequest)) as MessageRequest;
                MessageReceived?.Invoke(this, new MessageReceivedEventArgs(connection.Username, messageRequest.Target, messageRequest.Message, messageRequest.Groupname, DateTime.Now));
                break;

            case nameof(FiltrationRequest):
                var filtrationRequest = ((JObject)container.Payload).ToObject(typeof(FiltrationRequest)) as FiltrationRequest;
                FiltrationReceived?.Invoke(this, new FiltrationReceivedEventArgs(connection.Username, filtrationRequest.FirstDate, filtrationRequest.SecondDate, filtrationRequest.EventType));
                break;

            case nameof(CreateGroupRequest):
                var createGroupRequest = ((JObject)container.Payload).ToObject(typeof(CreateGroupRequest)) as CreateGroupRequest;
                createGroupRequest.UserList.Add(connection.Username);
                GroupCreated?.Invoke(this, new GroupCreatedEventArgs(createGroupRequest.Groupname, createGroupRequest.UserList));
                break;

            case nameof(LeaveGroupRequest):
                var leaveGroupRequest = ((JObject)container.Payload).ToObject(typeof(LeaveGroupRequest)) as LeaveGroupRequest;
                GroupLeaved?.Invoke(this, new GroupLeavedEventArgs(connection.Username, leaveGroupRequest.Groupname));
                break;
            }
        }
 private void SerialPort_ErrorReceived(
     object sender,
     SerialErrorReceivedEventArgs e)
 {
     _logger.LogDebug($"Received error on serial port '{SerialPort.PortName}'.");
     ErrorReceived?.Invoke(
         this,
         e);
 }
Exemple #16
0
        private void WriteErrorOutput(object sender, EventArgs e)
        {
            var eventArgs = e as ScriptHubDataReceivedEventArgs;

            _errors.Add(eventArgs.Data);
            _logger.LogToFile(_currentScript.Name, eventArgs.Data);

            ErrorReceived.Invoke(sender, new ScriptHubDataReceivedEventArgs(eventArgs.Data));
        }
        private void ErrorMarshal(object o)
        {
            if (ErrorReceived == null)
            {
                return;
            }

            ErrorReceived.Invoke(this, (ZusiTcpException)o);
        }
        public Notify WaitForNotify(Action action, int timeout, WaitHandle stop)
        {
            Notify notify = null;

            Events_.NotificationConsumer consumer = new Events_.NotificationConsumer(GetNotificationUri());
            NotifyReceived.Reset();
            ErrorReceived.Reset();
            consumer.OnError +=
                new Action <Exception>(
                    (err) =>
            {
                _rawData = consumer.RawData;
                RaiseDataReceived(consumer.RawData);
                OnNotifyError(err);
            }
                    );

            consumer.OnNotify += OnNotify;

            try
            {
                consumer.Start();
                if (action != null)
                {
                    action();
                }
                RaiseWaitStarted();

                int res = WaitHandle.WaitAny(new WaitHandle[] { NotifyReceived, ErrorReceived, stop }, timeout);
                if (res == 0)
                {
                    notify = _notify;
                    RaiseDataReceived(_rawData);
                    RaiseWaitFinished();
                }
                else if (res == 1)
                {
                    consumer.Stop();
                    throw _error;
                }
                else if (res == 2)
                {
                    // stop event
                    throw new StopEventException();
                }
                else
                {
                    RaiseTimeout();
                }
            }
            finally
            {
                consumer.Stop();
            }
            return(notify);
        }
Exemple #19
0
            /// <summary>Handler for all strings written to StdErr</summary>
            /// <param name="sendingProcess"></param>
            /// <param name="outLine"></param>
            private void ErrorHandler(object sendingProcess, DataReceivedEventArgs outLine)
            {
                if (!string.IsNullOrWhiteSpace(outLine.Data))
                {
                    ErrorReceived?.Invoke(this, outLine);

                    error.Append(outLine.Data + Environment.NewLine);
                    if (WriteToConsole)
                        Console.Error.WriteLine(outLine.Data);
                }
            }
 private void OnErrorReceived(Exception ex)
 {
     try {
         ErrorReceived?.Invoke(this, ex);
     }
     catch (Exception ex2) {
         const string TYPE_NAME   = nameof(UWPSerialDevice);
         const string MEMBER_NAME = nameof(OnErrorReceived);
         Debug.Fail($"Error in {TYPE_NAME}::{MEMBER_NAME} while raising ErrorReceived event: {ex2}");
     }
 }
Exemple #21
0
 // Use special status handler for the proxied messages: global errors and resets are specific
 // to the specific controller.  Rather than get involved in one controller's error handling,
 // just bypass it.
 private bool OnProxyStatus(Status st)
 {
     if (st.HasCommandError)
     {
         ErrorReceived.Raise(this, new ErrEventArgs(ErrorCode.InvalidProxiedCommand));
         return(false);
     }
     else
     {
         return(true);
     }
 }
Exemple #22
0
 public void ReadAsync()
 {
     try
     {
         port.BaseStream.BeginRead(byteBuffer, 0, byteBuffer.Length, OnRead, null);
     }
     catch (Exception ex)
     {
         ErrorReceived?.Invoke("ReadAsync");
         Console.WriteLine($"Не удалось получить ответ от {port.PortName}.\n{ex.Message}");
     }
 }
 void COM_ErrorReceived(object sender, SerialErrorReceivedEventArgs e)
 {
     System.IO.Ports.SerialPort sp = (System.IO.Ports.SerialPort)sender;
     loger.Log(
         new LogerMsg(
             String.Format(R.Error_Format,
                           e.EventType.ToString(), sp.PortName), TraceLevel.ERROR));
     if (ErrorReceived != null)
     {
         ErrorReceived.BeginInvoke(sender, e, null, null);
     }
 }
        private void Process_ErrorDataReceived(object sender, DataReceivedEventArgs e)
        {
            lock (_processLock)
            {
                if (_cancellationToken.IsCancellationRequested && !_process.HasExited)
                {
                    _process.Kill();
                    return;
                }
            }

            ErrorReceived?.Invoke(sender, e);
        }
Exemple #25
0
        // Each response from the board includes a status field, which is handled here for most messages.
        // If an error is indicated in the status field, issues a query for the error code.
        // If a reset is indicated, issues a query for the reset code.
        // Only one query issues; command error takes precedence over reset, reset takes
        // precedence over global error.
        // Returns False if the rest of the response should be ignored, True otherwise.
        virtual internal bool OnStatus(Status stat)
        {
            ICommand query = null;

            if (stat.HasCommandError || (stat.HasGlobalError && !stat.HasBeenReset))
            {
                query = new iCommand(_addr + GetError + DefaultChannel(),
                                     // Process the ER response's status: if HasCommandError, comm is not working:
                                     //   so, return false to prevent the callback action from executing.
                                     (st) => { return(!st.HasCommandError); },
                                     // Got an error response, raise any actual error in an event.
                                     (err) =>
                {
                    // TODO: global errors tend to be persistent; suppress raising them for every message
                    if (err != 0)
                    {
                        ErrorReceived.Raise(this, new ErrEventArgs(TranslateError(err)));
                    }
                });
            }
            else if (stat.HasBeenReset)
            {
                // query the reset parameter to find out why, and to clear it
                query = new iCommand(_addr + ResetController + DefaultChannel(),
                                     (st) => { return(!st.HasCommandError); },
                                     // Got a reset response, save the reported cause for later querying
                                     (cause) =>
                {
                    // Report reset as an error only if reset state is already known.
                    // A reset flag present in first communications with device does not result in error.
                    if (_reset_cause != ResetCause.UnknownResetState)
                    {
                        ErrorReceived.Raise(this, new ErrEventArgs(ErrorCode.ControllerReset));
                    }
                    _reset_cause = ResetCause.IsDefined(typeof(ResetCause), cause) ?
                                   (ResetCause)cause :
                                   ResetCause.UnrecognizedReset;
                });
            }
            // no error or reset, it's a good response; do a little housekeeping
            else if (_reset_cause == ResetCause.UnknownResetState)
            {
                _reset_cause = ResetCause.NoResetReported; // State is no longer unknown
            }
            if (query != null)
            {
                _board.Issue(query, true);  // Issue query right away, in front of other messages in queue
            }
            return(!stat.HasCommandError);
        }
        private void ErrorThread()
        {
            while (IsRunning)
            {
                _errorReceivedEvent.WaitOne();

                while (IsRunning && _errorQueue.TryDequeue(out DataReceivedEventArgs data))
                {
                    ErrorReceived?.Invoke(this, data);
                }

                _errorReceivedEvent.Reset();
            }
        }
Exemple #27
0
        /// <summary>
        /// Manages the ping timer, sending pings at the rate faster than requested by the server. If
        /// the ping timer handler does not run, it means the event loop is blocked, and the server
        /// will stop all devices and disconnect.
        /// </summary>
        /// <param name="aState">State of the Timer.</param>
        private async void OnPingTimer(object aState)
        {
            try
            {
                await SendMessageExpectOk(new Ping()).ConfigureAwait(false);
            }
            catch (Exception e)
            {
                ErrorReceived?.Invoke(_bpLogger, new ButtplugExceptionEventArgs(new ButtplugPingException(_bpLogger, "Exception thrown during ping update", ButtplugConsts.SystemMsgId, e)));

                // If SendMessageAsync throws, we're probably already disconnected, but just make sure.
                await DisconnectAsync().ConfigureAwait(false);
            }
        }
Exemple #28
0
        public override bool Process(byte[] buffer)
        {
            var matches =
                buffer.Length >= 3 &&
                buffer[2] == (byte)ReportType.Error;

            if (!matches)
            {
                return(false);
            }

            ErrorReceived?.Invoke();

            return(true);
        }
Exemple #29
0
        private void ConnectComplete(IAsyncResult ar)
        {
            try {
                _baseSocket.EndConnect(ar);                                          // -- End the connection event..
                IsConnected = true;                                                  // -- Flag the system as connected
                _baseStream = _baseSocket.GetStream();
                _baseStream.BeginRead(_readBuffer, 0, ReadSize, ReadComplete, null); // -- Begin reading data

                Connected?.SafeRaise(new SocketConnectedArgs(this));                 // -- Trigger the socket connected event.
            }
            catch (Exception ex) {
                IsConnected = false;
                ErrorReceived?.SafeRaise(new SocketErrorArgs(this, "Error during connect: " + ex.Message));
            }
        }
Exemple #30
0
        /// <summary>
        /// ボナンザからのエラー読み込みを行います。
        /// </summary>
        private void ErrorReadMain(object arg)
        {
            var reader = (StreamReader)arg;

            while (!this.aborted)
            {
                var line = reader.ReadLine();
                if (line == null)
                {
                    break;
                }

                ErrorReceived.SafeRaiseEvent(
                    this, new BonanzaReceivedCommandEventArgs(line));
            }
        }