I was wondering how I can store variables server side that can be fired to connected clients when called?.
I use a concurrent dictionary to keep track of the connections GUID’s and was wondering can I store strings or other data types on the server , for example the last 10 messages , so when a new connection occurs the client gets the last 10 messages even though they where not connected beforehand.
I could see many uses for it but don’t see much on this , is this frowned upon?, or bad practice ?. I can see that storing huge strings server side could cause lots of issues. But is what I am proposing really that bad?.
No it’s not frowned upon at all. JabbR, which is the flagship application for testing SignalR, is a chat system much like IRC, stores “rooms”, messages, user names/identity info, etc.
How you store those is up to you. JabbR happens to be using ADO.NET Entity Framework to store the data in a SQL DB. You could obviously do the same or use RavenDB or Azure Table Storage or whatever.
All you need to do is implement your logic in a Hub and then, when a message comes in, you do whatever kind of data access/storage makes sense for that kind of message.
I highly recommend taking a look at the JabbR source code, which is available here on GitHub, to get a better understanding of how this might work for you.