private bool TryHandleAuthenticationResponses(string message)
        {
            if (AuthenticationResponse.TryParse(Serializer, message, out var authenticationResponse))
            {
                Streams.AuthenticationResponseSubject.OnNext(authenticationResponse);
                return(true);
            }

            return(false);
        }
Exemple #2
0
        private void MessageReceived(object sender, BitmexSocketMessageEventArgs e)
        {
            if (PongResponse.TryParse(e.Message, OnPongResponse))
            {
                return;
            }

            var jsonElement = JsonDocument.Parse(e.Message).RootElement;

            if (jsonElement.TryGetProperty("table", out _))
            {
                if (TableResponse <AffiliateDto> .TryHandle(jsonElement, OnAffiliateResponse, SubscriptionType.affiliate))
                {
                    return;
                }
                if (TableResponse <AnnouncementDto> .TryHandle(jsonElement, OnAnnouncementResponse, SubscriptionType.announcement))
                {
                    return;
                }
                if (TableResponse <ChatDto> .TryHandle(jsonElement, OnChatResponse, SubscriptionType.chat))
                {
                    return;
                }
                if (TableResponse <ChatConnectedDto> .TryHandle(jsonElement, OnChatConnectedResponse, SubscriptionType.connected))
                {
                    return;
                }
                if (TableResponse <ExecutionDto> .TryHandle(jsonElement, OnExecutionResponse, SubscriptionType.execution))
                {
                    return;
                }
                if (TableResponse <FundingDto> .TryHandle(jsonElement, OnFundingResponse, SubscriptionType.funding))
                {
                    return;
                }
                if (TableResponse <InstrumentDto> .TryHandle(jsonElement, OnInstrumentResponse, SubscriptionType.instrument))
                {
                    return;
                }
                if (TableResponse <InsuranceDto> .TryHandle(jsonElement, OnInsuranceResponse, SubscriptionType.insurance))
                {
                    return;
                }
                if (TableResponse <LiquidationDto> .TryHandle(jsonElement, OnLiquidationResponse, SubscriptionType.liquidation))
                {
                    return;
                }
                if (TableResponse <MarginDto> .TryHandle(jsonElement, OnMarginResponse, SubscriptionType.margin))
                {
                    return;
                }
                if (TableResponse <OrderDto> .TryHandle(jsonElement, OnOrderResponse, SubscriptionType.order))
                {
                    return;
                }
                if (TableResponse <OrderBook10Dto> .TryHandle(jsonElement, OnOrderBook10Response, SubscriptionType.orderBook10))
                {
                    return;
                }
                if (TableResponse <OrderBookDto> .TryHandle(jsonElement, OnOrderBookL2Response, SubscriptionType.orderBookL2))
                {
                    return;
                }
                if (TableResponse <OrderBookDto> .TryHandle(jsonElement, OnOrderBookL225Response, SubscriptionType.orderBookL2_25))
                {
                    return;
                }
                if (TableResponse <PositionDto> .TryHandle(jsonElement, OnPositionResponse, SubscriptionType.position))
                {
                    return;
                }
                if (TableResponse <NotificationDto> .TryHandle(jsonElement, OnPrivateNotificationResponse, SubscriptionType.privateNotifications))
                {
                    return;
                }
                if (TableResponse <NotificationDto> .TryHandle(jsonElement, OnPublicNotificationResponse, SubscriptionType.publicNotifications))
                {
                    return;
                }
                if (TableResponse <QuoteDto> .TryHandle(jsonElement, OnQuoteResponse, SubscriptionType.quote))
                {
                    return;
                }
                if (TableResponse <QuoteDto> .TryHandle(jsonElement, OnQuote1DResponse, SubscriptionType.quoteBin1d))
                {
                    return;
                }
                if (TableResponse <QuoteDto> .TryHandle(jsonElement, OnQuote1HResponse, SubscriptionType.quoteBin1h))
                {
                    return;
                }
                if (TableResponse <QuoteDto> .TryHandle(jsonElement, OnQuote1MResponse, SubscriptionType.quoteBin1m))
                {
                    return;
                }
                if (TableResponse <QuoteDto> .TryHandle(jsonElement, OnQuote5MResponse, SubscriptionType.quoteBin5m))
                {
                    return;
                }
                if (TableResponse <SettlementDto> .TryHandle(jsonElement, OnSettlementResponse, SubscriptionType.settlement))
                {
                    return;
                }
                if (TableResponse <TradeDto> .TryHandle(jsonElement, OnTradeResponse, SubscriptionType.trade))
                {
                    return;
                }
                if (TableResponse <TradeDto> .TryHandle(jsonElement, OnTradeResponse, SubscriptionType.trade))
                {
                    return;
                }
                if (TableResponse <TradeBucketedDto> .TryHandle(jsonElement, OnTradeBucketed1DResponse, SubscriptionType.tradeBin1d))
                {
                    return;
                }
                if (TableResponse <TradeBucketedDto> .TryHandle(jsonElement, OnTradeBucketed1HResponse, SubscriptionType.tradeBin1h))
                {
                    return;
                }
                if (TableResponse <TradeBucketedDto> .TryHandle(jsonElement, OnTradeBucketed1MResponse, SubscriptionType.tradeBin1m))
                {
                    return;
                }
                if (TableResponse <TradeBucketedDto> .TryHandle(jsonElement, OnTradeBucketed5MResponse, SubscriptionType.tradeBin5m))
                {
                    return;
                }
                if (TableResponse <TransactionDto> .TryHandle(jsonElement, OnTransactionResponse, SubscriptionType.transact))
                {
                    return;
                }
                if (TableResponse <WalletDto> .TryHandle(jsonElement, OnWalletResponse, SubscriptionType.wallet))
                {
                    return;
                }
            }
            if (AuthenticationResponse.TryParse(jsonElement, OnAuthenticationResponse))
            {
                return;
            }
            if (CancelAllAfterResponse.TryHandle(jsonElement, OnCancelAllAfterResponse))
            {
                return;
            }
            //if (ErrorResponse.TryParse(jsonElement, OnErrorResponse)) return;
            if (SubscribeResponse.TryParse(jsonElement, OnSubscribeResponse))
            {
                return;
            }
            if (UnsubscribeResponse.TryParse(jsonElement, OnUnsubscribeResponse))
            {
                return;
            }
            if (WelcomeInfoResponse.TryParse(jsonElement, OnWelcomeInfoResponse))
            {
                return;
            }

            _logger.LogWarning($"Unknown type message.{e.Message}");
        }