I am new to signalr and I want to know if messages can be broadcast only to related records not for users. By that what I mean is suppose I have an master table
masterid
1
2
3
Detail table
DetailID Masterid status
id1 1 pass
id2 1 fail
id3 2 pass
id4 3 pass
id5 1 fail
I am on the webpage and I have masterID 1 record open. I modify the status in detailtable record id1,id2 and I want the data update notification to be sent to my webpage. If I ahve another tab or another user who has open the masterid 2 on thier webpage, signalr must broadcast message only to masterID 1 since that was modified. Masterid2 webpage must not get any broadcast notification. Is this possible in signalr. My webpage is not based on user, or login, it is mostly machine. each machine can have different masterid's open on their browsers.
Is SignalR the right way to go and how to broadcast only to modified clients?
What I have tried:
I tried the BlogDemos sample and
using (var command = new SqlCommand(@"SELECT [MessageID], [Message], [EmptyMessage], [Date] FROM [dbo].[Messages] where messageid=1", connection))
//using (var command = new SqlCommand(@"SELECT [MessageID] FROM [dbo].[Messages]", connection))
{
command.Notification = null;
var dependency = new SqlDependency(command);
dependency.OnChange += new OnChangeEventHandler(dependency_OnChange);
if (connection.State == ConnectionState.Closed)
connection.Open();
var reader = command.ExecuteReader();
while (reader.Read())
{
messages.Add(item: new Messages { MessageID = (int)reader["MessageID"], Message = (string)reader["Message"], EmptyMessage = reader["EmptyMessage"] != DBNull.Value ? (string)reader["EmptyMessage"] : "", MessageDate = Convert.ToDateTime(reader["Date"]) });
}
}
where I specified messageid1, hoping only when record with messageid 1 gets modified broadcast the data, don't broadcast to all clients. broadcast it to only clients who have messageid record open. But it broadcasts even if some other records was modified