ExportClient class has OnTickRecieved event, which helps me to receive some data (bid prices from market). All I want - is to receive this data real-time on my charts in browser. When I press Go button on UI-side, it calls Go() method in controller, and then nothing is happening. And it's logical - because after request on server, controller is destroyed.
My question is: how to force a server to send me an event-data constantly?
Controller code:
public class ChartsController : Controller
{
[HttpGet]
public void Go()
{
var exportClient = new ExportClient();
exportClient.TickRecieved += exportClient_TickRecieved;
}
private void exportClient_TickRecieved(object sender, TickRecievedEventArgs args)
{
ImpulserHub.SendBidPrice(args.Bid);
}
}
Hub code:
[HubName("impulserHub")]
public class ImpulserHub : Hub
{
public static void SendBidPrice(double bid)
{
var hubContext = GlobalHost.ConnectionManager.GetHubContext<ImpulserHub>();
hubContext.Clients.All.sendBidPrice(bid);
}
}
And I have tested SignalR, this code works fine:
[HttpGet]
public void Go()
{
ImpulserHub.SendBidPrice(3.3333333); // I have received this number on UI
}