0

I am working on a Chat Server Application in Asp.Net with C#.

Suppose there are 5 users online say User A,B,C,D,E. Suppose A sends a message in chatbox to user B, so how the chatbox (Textbox/Textarea of chat) of User B will load the new content?

One Option is to refresh the chatbox every 10Seconds or 15 seconds but it's pretty unuseful way because as if there is no new message for the user the chatbox will still be refreshed.


I have an aspx page say client.aspx with client.aspx.cs as code behind file and server file say server.cs. There is a send button on aspx page on click event of this button i called a method of my server file say UpdateChatbox(from,to,content) now the from is User A, to is User B and content is my msg in chatbox, Now the question is : How Server.cs file update the ChatBox on client.aspx page of User B?

1

SignalR is what you are looking for.

From the website:

ASP.NET SignalR is a new library for ASP.NET developers that makes developing real-time web functionality easy. SignalR allows bi-directional communication between server and client. Servers can now push content to connected clients instantly as it becomes available. SignalR supports Web Sockets, and falls back to other compatible techniques for older browsers. SignalR includes APIs for connection management (for instance, connect and disconnect events), grouping connections, and authorization.

You can have a look inside JabbR source code to see what it can do and how to do it.

0

Without knowing exactly how your Server and Client looks like...

How about setting it up so when the Server receives a new message it will fire of an event to all clients that are online, and make sure that the clients hook into these events.

As I said, there's not really much to go on since you don't go deeper into how the Server and Client looks like and are set up, but this seems to be the most straight-forward approach.

  • Sorry, I can't understand your words – Abhay Prince Mar 3 '14 at 8:38
  • What exactly don't you understand? – user1021726 Mar 3 '14 at 9:28
  • Without knowing exactly how your Server and Client looks like...?????? – Abhay Prince Mar 3 '14 at 11:16
  • Yes... How they are programmed and how they are designed to work and talk to eachother – user1021726 Mar 3 '14 at 11:28
  • I am updating the question to more detail ..... – Abhay Prince Mar 3 '14 at 11:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.