35 lines
753 B
C#
35 lines
753 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Threading.Channels;
|
|
using System.Threading.Tasks;
|
|
using Microsoft.AspNetCore.SignalR;
|
|
|
|
namespace HHWMS.Web
|
|
{
|
|
public class StockTickerHub : Hub
|
|
{
|
|
private readonly StockTicker _stockTicker;
|
|
|
|
public StockTickerHub(StockTicker stockTicker)
|
|
{
|
|
_stockTicker = stockTicker;
|
|
}
|
|
|
|
public IEnumerable<Stock> GetAllStocks()
|
|
{
|
|
return _stockTicker.GetAllStocks();
|
|
}
|
|
|
|
public ChannelReader<Stock> StreamStocks()
|
|
{
|
|
return _stockTicker.StreamStocks().AsChannelReader(10);
|
|
}
|
|
|
|
public async Task OpenMarket()
|
|
{
|
|
await _stockTicker.OpenMarket();
|
|
}
|
|
|
|
}
|
|
}
|