예제 #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 "C":
                        ForexQuote quote = JsonConvert.DeserializeObject <ForexQuote>(ObjJSONText);
                        if (quote != null)
                        {
                            OnForexQuoteEvent?.Invoke(quote);
                        }
                        break;

                    case "CA":
                        ForexAggregate forexAgg = JsonConvert.DeserializeObject <ForexAggregate>(ObjJSONText);
                        if (forexAgg != null)
                        {
                            OnForexAggEvent?.Invoke(forexAgg);
                        }
                        break;

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

                    default:
                        break;
                    }
                }
            }
            catch (System.Exception ex)
            {
                HandleJSONTextException("websocket_MessageReceived", JSONText, ex);
            }
        }
예제 #2
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);
            }
        }
예제 #3
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);
            }
        }
예제 #4
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 "XQ":
                        CryptoQuote quote = JsonConvert.DeserializeObject <CryptoQuote>(ObjJSONText);
                        if (quote != null)
                        {
                            OnCryptoQuoteEvent?.Invoke(quote);
                        }
                        break;

                    case "XT":
                        CryptoTrade trade = JsonConvert.DeserializeObject <CryptoTrade>(ObjJSONText);
                        if (trade != null)
                        {
                            OnCryptoTradeEvent?.Invoke(trade);
                        }
                        break;

                    case "XA":
                        CryptoAggregate cryptoAgg = JsonConvert.DeserializeObject <CryptoAggregate>(ObjJSONText);
                        if (cryptoAgg != null)
                        {
                            OnCryptoAggEvent?.Invoke(cryptoAgg);
                        }
                        break;

                    case "XS":
                        CryptoSIP CryptoSIPRef = JsonConvert.DeserializeObject <CryptoSIP>(ObjJSONText);
                        if (CryptoSIPRef != null)
                        {
                            OnCryptoSIPEvent?.Invoke(CryptoSIPRef);
                        }
                        break;

                    case "XL2":
                        CryptoLevel2 cryptoLevel2 = JsonConvert.DeserializeObject <CryptoLevel2>(ObjJSONText);
                        if (cryptoLevel2 != null)
                        {
                            OnCryptoLevel2Event?.Invoke(cryptoLevel2);
                        }
                        break;

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

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