void IApplicationRecorder.RecordError(string tag, string message) { AppErrorCalledTimes++; var formatted = $"{tag}:{message}{Environment.NewLine}"; _messageCache.AddMessage(formatted); AppErrorCache += formatted; RecordReceived?.Invoke(formatted); }
protected virtual void OnRecordReceived(DNSLookupRecordArgs e) { RecordReceived?.Invoke(this, e); }
void IApplicationRecorder.RecordError(string tag, string message) { _messagesCache.AddMessage(FormatInfoRecord(tag, message)); RecordReceived?.Invoke(FormatErrorRecord(tag, message)); }
/// <summary> /// Handler for streaming message. /// </summary> /// <param name="sender">Sender</param> /// <param name="args">Args</param> private void StreamingMessageHandler(object sender, IncomingMessageArgs args) { var message = args.Message.Parameters.GetString("update"); JSONObject responseBody = (JSONObject)JSONObject.Parse(message); string commandName = responseBody["command"].ToString(); if (RecordReceived != null) { RecordReceived.Invoke(message); } switch (commandName) { case "tickPrices": TickRecord tickRecord = new TickRecord((JSONObject)responseBody["data"]); if (TickPricesRecordReceived != null) { TickPricesRecordReceived.Invoke(tickRecord); } break; case "trade": StreamingTradeRecord tradeRecord = new StreamingTradeRecord((JSONObject)responseBody["data"]); if (TradeRecordReceived != null) { TradeRecordReceived.Invoke(tradeRecord); } break; case "indicators": IndicatorsRecord balanceRecord = new IndicatorsRecord((JSONObject)responseBody["data"]); if (AccountIndicatorsRecordReceived != null) { AccountIndicatorsRecordReceived.Invoke(balanceRecord); } break; case "orderStatus": OrderStatusRecord tradeStatusRecord = new OrderStatusRecord((JSONObject)responseBody["data"]); if (OrderStatusRecordReceived != null) { OrderStatusRecordReceived.Invoke(tradeStatusRecord); } break; case "profit": ProfitRecord profitRecord = new ProfitRecord((JSONObject)responseBody["data"]); if (ProfitRecordReceived != null) { ProfitRecordReceived.Invoke(profitRecord); } break; case "news": NewsRecord newsRecord = new NewsRecord((JSONObject)responseBody["data"]); if (NewsRecordReceived != null) { NewsRecordReceived.Invoke(newsRecord); } break; case "keepAlive": KeepAliveRecord keepAliveRecord = new KeepAliveRecord((JSONObject)responseBody["data"]); if (KeepAliveRecordReceived != null) { KeepAliveRecordReceived.Invoke(keepAliveRecord); } break; case "candle": StreamingCandleRecord candleRecord = new StreamingCandleRecord((JSONObject)responseBody["data"]); if (CandleRecordReceived != null) { CandleRecordReceived.Invoke(candleRecord); } break; case "error": StreamingErrorRecord streamingErrorRecord = new StreamingErrorRecord((JSONObject)responseBody["data"]); if (ErrorRecordReceived != null) { ErrorRecordReceived.Invoke(streamingErrorRecord); } break; default: throw new APICommunicationException("Unknown streaming record received"); } }