I'm getting back into stateless web dev, so I'm a little rusty right now coming from desktop app development.
Anyway, I have two projects: (1) one is a DLL that subscribes to and handles all the websocket data and (2) the other is a .NET Core web app that references the DLL. I would like to update the View in the web app in real-time from the websocket data. I'm trying to figure out how to wire everything up so that the view updates in real-time with the websocket data.
In my controller, I have this:
public async Task<IActionResult> Index(HomeModel model, string button)
{
model.Trader.TdaClient.TdaWebsocket = new TdaWebsocket(model.Trader.TdaClient).Login();
model.Trader.TdaClient.TdaWebsocket.StreamingNotificationResponseEventHandler += TdaWebsocket_StreamingNotificationResponseEventHandler;
model.Trader.TdaClient.TdaWebsocket.StreamCandles(new List<string>() { model.StreamInputs.symbol });
return View(model);
}
private void TdaWebsocket_StreamingNotificationResponseEventHandler(object sender, Responses e)
{
///
}
The event handler method gets hit, but am not sure how to update the View in real-time. I know that I could do all the websocket logic in JavaScript, but would rather keep it in the DLL project.
Basically, I need the websocket data to be sent to a .js file to update a chart in real-time on a partial view via a JavaScript function. Is this possible with the current configuration?
I've looked into SignalR, but cannot find any examples of how to relay the stream to the view. I think I might have to use SignalR, or code some kind of wrapper for the websocket? I'm a little stuck right now so any help would be great.