Ejemplo n.º 1
0
        // =====>>>>>>>>>> JSONText Message Received

        public override void OnWebSocketJSONText(string JSONText)
        {
            try
            {
                string ObjJSONText;

                List <object> PGBaseList = JsonConvert.DeserializeObject <List <object> >(JSONText);
                foreach (var PGBase in PGBaseList)
                {
                    ObjJSONText = PGBase.ToString();
                    PolygonBase pGBase = JsonConvert.DeserializeObject <PolygonBase>(ObjJSONText);

                    switch (pGBase.ev)
                    {
                    case "Q":
                        Quote quote = JsonConvert.DeserializeObject <Quote>(ObjJSONText);
                        if (quote != null)
                        {
                            OnQuoteEvent?.Invoke(quote);
                        }
                        break;

                    case "T":
                        Trade trade = JsonConvert.DeserializeObject <Trade>(ObjJSONText);
                        if (trade != null)
                        {
                            OnTradeEvent?.Invoke(trade);
                        }
                        break;

                    case "status":
                        Status StatusIn = JsonConvert.DeserializeObject <Status>(ObjJSONText);
                        HandleStatusMessage(StatusIn);
                        break;

                    case "A":
                        ASecond ASecRef = JsonConvert.DeserializeObject <ASecond>(ObjJSONText);
                        if (ASecRef != null)
                        {
                            OnASecondEvent?.Invoke(ASecRef);
                        }
                        break;

                    case "AM":
                        AMinute AMinRef = JsonConvert.DeserializeObject <AMinute>(ObjJSONText);
                        if (AMinRef != null)
                        {
                            OnAMinuteEvent?.Invoke(AMinRef);
                        }
                        break;

                    default:
                        break;
                    }
                }
            }
            catch (System.Exception ex)
            {
                HandleJSONTextException("websocket_MessageReceived", JSONText, ex);
            }
        }
Ejemplo n.º 2
0
        // =====>>>>>>>>>> JSONText Message Received

        public override void OnJSONTextReceived(string JSONText)
        {
            try
            {
                string ObjJSONText;

                List <object> PGBaseList = JsonConvert.DeserializeObject <List <object> >(JSONText);
                foreach (var PGBase in PGBaseList)
                {
                    ObjJSONText = PGBase.ToString();
                    PolygonBase PGBaseRef = JsonConvert.DeserializeObject <PolygonBase>(ObjJSONText);

                    switch (PGBaseRef.ev)
                    {
                    case "Q":
                        Quote QuoteRef = JsonConvert.DeserializeObject <Quote>(ObjJSONText);
                        if (QuoteRef != null)
                        {
                            OnQuoteEvent?.Invoke(QuoteRef);
                        }
                        break;

                    case "T":
                        Trade TradeRef = JsonConvert.DeserializeObject <Trade>(ObjJSONText);
                        if (TradeRef != null)
                        {
                            OnTradeEvent?.Invoke(TradeRef);
                        }
                        break;

                    case "status":
                        Status StatusRef = JsonConvert.DeserializeObject <Status>(ObjJSONText);
                        if (StatusRef != null)
                        {
                            if (StatusRef.status.Contains(PGStatusMessages.AuthSuccess))
                            {
                                if (IsReconnect)
                                {
                                    FireOnPGRestartedEvent();
                                }

                                FireOnPGReadyEvent(IsReconnect);
                            }

                            OnPGStatusEvent?.Invoke(StatusRef.status, StatusRef.message);
                        }
                        break;

                    case "A":
                        ASecond ASecRef = JsonConvert.DeserializeObject <ASecond>(ObjJSONText);
                        if (ASecRef != null)
                        {
                            OnASecondEvent?.Invoke(ASecRef);
                        }
                        break;

                    case "AM":
                        AMinute AMinRef = JsonConvert.DeserializeObject <AMinute>(ObjJSONText);
                        if (AMinRef != null)
                        {
                            OnAMinuteEvent?.Invoke(AMinRef);
                        }
                        break;

                    default:
                        break;
                    }
                }
            }
            catch (System.Exception ex)
            {
                HandleJSONTextException("websocket_MessageReceived", JSONText, ex);
            }
        }