Reputation: 1
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);
}
Upvotes: 0
Views: 1648
Reputation: 1298
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
Hope this help.
Upvotes: 1
Reputation: 1007
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
Upvotes: 1