Last post Oct 04, 2014 10:47 AM by Barney127
Oct 03, 2014 12:06 PM|Barney127|LINK
imagine a chat application where each hub is a room.
My goal is to have every client updated with all messages sent to a room, even those sent before the connection.
There is an established design pattern to solve this kind of problem?
My doubt is that a client may lose some message. How can I avoid this problem?
Oct 03, 2014 02:22 PM|Rajneesh Verma|LINK
Use SignalR to post real time data
Oct 03, 2014 02:29 PM|Rion Williams|LINK
If you are interested in any real-time applications like chatting, I would encourage you to look into
SignalR and many of the tutorials that this site offers. SignalR has built-in functions to easily determine where specific messages are broadcast and it is fairly easy to pick up.
You might try taking a look at
JabbR, which is a large-scale chatting application that is completely open-source and built atop SignalR. It has the type of functionality that you are looking for with regards to loading previous messages (even prior to the connection). You can
take a look at the repository for it here. If that seems a bit too daunting, I'm sure that you could easily search around for something like "SignalR load previous messages example" on your favorite search engine
to get a few other ideas.
Basically, you would really just need to store all of the messages that were transmitted within a database and when a user is connected pull x number of previous messages into the chat window. Then when the user attempted to scroll up in the window (to see
things he / she may have missed), you'll just make an AJAX request and pull down x additional previous messages to display above the current set. This will function very similar to how paging is often handled within data-grids and in other areas.
Oct 04, 2014 10:47 AM|Barney127|LINK
after some thinking I created this code, is this solution the best way to solve this problem?
public class RoomHub : Hub
private IChatRepository _chatRepository;
private object _locker = new object();
public RoomHub(IChatRepository chatRepository)
_chatRepository = chatRepository;
public override Task OnConnected()
public void NewChatEntry(string newChatEntry)