0

I have a question about signalR simple chat application. We have an app working on local host and people can join and chat with each other. Here is the problem we could not specify which message will send to which user? I mean we could not create room?

here is the code part

private void BroadCastMessage(string message)
{
    var clients = Hub.GetClients<ChatHub>();

    clients.newMessage(message);
    clients.isAlive();
}

public void GetClients()
{
    System.Web.Script.Serialization.JavaScriptSerializer oSerializer = new System.Web.Script.Serialization.JavaScriptSerializer();
    string sJSON = oSerializer.Serialize(Clients);

    var clients = Hub.GetClients<ChatHub>();
    clients.userList(sJSON);
}
Sam
  • 4,475
  • 2
  • 28
  • 31

2 Answers2

1

SignalR supports creation of groups which allow you to send messages to a specific subset of users. The sample chat application in the SignalR project on GitHub demonstrates how to create rooms. The GitHub link:

https://github.com/signalr/signalr

Abhishek Nanda
  • 1,007
  • 1
  • 8
  • 14
1

The signalR have supported for chat group to create a chat room. But the question at here is how. You can take reference follow the links below. They are really good for newbie like you,

http://www.codeproject.com/Articles/562023/Asp-Net-SignalR-Chat-Room

To create group chat :

http://www.bluelemoncode.com/post/2013/02/17/One-to-one-chat-using-Aspnet-SignalR-groups.aspx

or

SignalR and Joining Groups

Hope this help.

Community
  • 1
  • 1
Toan Vo
  • 1,270
  • 9
  • 19