public async Task<IActionResult> Index() { _logger.LogInformation("Start Capture"); //var price = await _marketFeed.StartBTCCapture(); //var incomingBTC = await _binanceSocketClient.SubscribeToTradeUpdatesAsync("BTCUSD", (data) => //{ // //(data); // // _logger.LogInformation(data.Price.ToString()); // Console.WriteLine(data.Price); //}); List<TradeResult> trades = new List<TradeResult>(); await GetPartial(trades); //_logger.LogInformation(price.Data); //var conn = new WebSocket(); //HttpListener httpListener = new HttpListener(); //httpListener.Prefixes.Add("ws://localhost:50021/StartBTCCapture"); //httpListener.Start(); //var buffer = new byte[1024 * 4]; //HttpListenerContext context = await httpListener.GetContextAsync(); //if (context.Request.IsWebSocketRequest) //{ // HttpListenerWebSocketContext webSocketContext = await context.AcceptWebSocketAsync(null); // WebSocket webSocket = webSocketContext.WebSocket; // while (webSocket.State == WebSocketState.Open) // { // await webSocket.ReceiveAsync(new ArraySegment<byte>(buffer), CancellationToken.None); // } //} return View(); } public async Task<IActionResult> GetPartial(List<TradeResult> trades) { var incomingBTC = await _binanceSocketClient.SubscribeToTradeUpdatesAsync("BTCUSD", (data) => { //(data); // _logger.LogInformation(data.Price.ToString()); Console.WriteLine(data.Price); trades.Add(new TradeResult { Price = data.Price }); }); return PartialView("BoxView", trades); } //Partial <div class="container"> <form> <table> <tr> <th>Price</th> </tr> @foreach(var obj in Model) { <tr> <td> @obj.Price.ToString() </td> </tr> } </table> <input type="submit" value="btn" /> </form> </div>
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)