Пример #1
0
        public async Task ReceiveOrderBook()
        {
            await _clientWebSocket.ConnectAsync(CancellationToken.None);

            var info = await _clientWebSocket.GetResponseAsync(CancellationToken.None);

            Assert.NotNull(info);

            var request = SubscribeOrderBooksRequest.BuildRequest("BTCUSD", "", "R0");

            await _clientWebSocket.SendRequestAsync(request, CancellationToken.None);

            var successfull = await _clientWebSocket.GetResponseAsync(CancellationToken.None);

            var respose = JsonConvert.DeserializeObject <SubscribedResponse>(successfull);

            var snapshot = await _clientWebSocket.GetResponseAsync(CancellationToken.None);

            OrderBookSnapshotResponse.Parse(snapshot);

            var update = await _clientWebSocket.GetResponseAsync(CancellationToken.None);

            OrderBookUpdateResponse.Parse(update);

            Assert.NotNull(respose);
        }
        public async Task ReceiveOrderBook()
        {
            await _clientWebSocket.ConnectAsync();

            var info = await _clientWebSocket.GetResponseAsync();

            Assert.NotNull(info);

            var request = new SubscribeRequest
            {
                Event   = "subscribe",
                Channel = "book",
                Pair    = "BTCUSD",
                Prec    = "R0"
            };
            await _clientWebSocket.SendRequestAsync(request);

            var successfull = await _clientWebSocket.GetResponseAsync();

            var respose = JsonConvert.DeserializeObject <SubscribedResponse>(successfull);

            var snapshot = await _clientWebSocket.GetResponseAsync();

            var obsh = OrderBookSnapshotResponse.Parse(snapshot);


            var update = await _clientWebSocket.GetResponseAsync();

            var upd = OrderBookUpdateResponse.Parse(update);

            Assert.NotNull(respose);
        }
        private async Task <dynamic> GetResponse()
        {
            var json = await Messenger.GetResponseAsync(CancellationToken);

            var result = EventResponse.Parse(json) ??
                         TickerResponse.Parse(json) ??
                         OrderBookSnapshotResponse.Parse(json) ??
                         (dynamic)OrderBookUpdateResponse.Parse(json) ??
                         HeartbeatResponse.Parse(json);

            return(result);
        }