signalr test
This commit is contained in:
1 parent
a87e5e5ff9
commit
d250bca681
16 files changed
+8779
-62
No files matched your search
@@ -0,0 +1,48 @@
|
||||
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 string GetMarketState()
|
||||
{
|
||||
return _stockTicker.MarketState.ToString();
|
||||
}
|
||||
|
||||
public async Task OpenMarket()
|
||||
{
|
||||
await _stockTicker.OpenMarket();
|
||||
}
|
||||
|
||||
public async Task CloseMarket()
|
||||
{
|
||||
await _stockTicker.CloseMarket();
|
||||
}
|
||||
|
||||
public async Task Reset()
|
||||
{
|
||||
await _stockTicker.Reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user