Beispiel #1
0
        public override Task GetTickerUpdates(Empty request, IServerStreamWriter <TickerUpdate> responseStream, ServerCallContext context)
        {
            Console.WriteLine($"New ticker stream connect. peer:{context.Peer}");

            var streamInfo = new StreamInfo <TickerUpdate>
            {
                Stream = responseStream,
                Peer   = context.Peer
            };

            return(_tickerUpdateService.RegisterStream(streamInfo));
        }
Beispiel #2
0
        public override Task GetTradeUpdates(Empty request, IServerStreamWriter <TradeUpdate> responseStream, ServerCallContext context)
        {
            Console.WriteLine($"New trade stream connect. peer:{context.Peer}");

            var streamInfo = new StreamInfo <TradeUpdate>
            {
                Stream           = responseStream,
                CancelationToken = context.CancellationToken,
                Key  = context.GetHttpContext().User.GetWalletId(),
                Peer = context.Peer
            };

            return(_tradeUpdateService.RegisterStream(streamInfo));
        }
Beispiel #3
0
        public override Task GetOrderbookUpdates(OrderbookUpdatesRequest request,
                                                 IServerStreamWriter <Orderbook> responseStream,
                                                 ServerCallContext context)
        {
            Console.WriteLine($"New orderbook stream connect. peer:{context.Peer}");

            var streamInfo = new StreamInfo <Orderbook>
            {
                Stream = responseStream,
                Key    = request.AssetPairId,
                Peer   = context.Peer
            };

            return(_orderbookUpdateService.RegisterStream(streamInfo));
        }
Beispiel #4
0
        public override async Task GetBalanceUpdates(Empty request, IServerStreamWriter <BalanceUpdate> responseStream, ServerCallContext context)
        {
            Console.WriteLine($"New balance stream connect. peer:{context.Peer}");

            string walletId = context.GetHttpContext().User.GetWalletId();

            var balances = await _balanceService.GetBalancesAsync(walletId);

            var streamInfo = new StreamInfo <BalanceUpdate>
            {
                Stream           = responseStream,
                CancelationToken = context.CancellationToken,
                Key  = context.GetHttpContext().User.GetWalletId(),
                Peer = context.Peer
            };

            var initData = new BalanceUpdate();

            initData.Balances.AddRange(_mapper.Map <List <Balance> >(balances));
            await _balanceUpdateService.RegisterStream(streamInfo, initData);
        }