This is a very common architectural problem - the combination of a living stream with a "state of the world." What you want to do is use SignalR to broadcast live messages to current subscribers (which is good) and have a separate API call to connect clients to receive historical messages.
In clients, you send logic, which first subscribes to a direct stream of SignalR messages, and then requests the history of past messages ("state of the world") - as a rule, it is best to discard it as a simple ordered list.
There is an indispensable condition for race, which can lead to the receipt of a message in real time and in history - so you should take care to remove duplicates or โcancel the deletionโ of your message list.
How you save messages can be treated as a separate issue.
This denouement of the story and the live stream gives flexibility in how you deal with both, and offers opportunities for increased efficiency, such as swapping in the story, rather than capturing it all, for example.
There are several questions and answers that talk about ways to use Rx to combine history and live data - you will need to do this in client javascript, and I'm not very good in rx js.
Take a look at Merging historical and current stock price data with Rx to discuss this issue, as well as these two equivalents of observed transactions? - I have an example code in the latter case, which is a purely .NET script.
source share