I send messages to individual users depending on their roles, to ensure that I have the following code snippet:
public static void Add(Guid userId, IEnumerable<SnapshotItem> snapshot) { var hub = GlobalHost.ConnectionManager.GetHubContext<FeedbackHub>(); var items = ApplicationDbContext.Instance.InsertSnapshot(userId, Guid.NewGuid(), snapshot); foreach (var sendOperation in ConnectedUsers.Instance.EnumerateSendOperations(items)) { hub.Clients.Users(sendOperation.Groups.SelectMany(x => x.Users).Select(x => x.Id).ToList()).OnDataFeedback(sendOperation.Items); } }
I'm not sure why I have to call .ToList() every time I need to send something, my backup store is HashSet<String> , and I want SignalR to work with this type of storage and not convert it to List every times, since it clearly consumes processing power and memory.
Since in the backstage SignalR does a simple iteration over the users or connectionIds argument, it would be wiser to use IEnumerable instead of IList , I looked at the sources of SignalR, shouldn't it be hard to achieve? Is there a special reason for using IList ?
Edit
Created a problem on the SignalR github page, you have to wait for one of the actual developers to clarify the situation ...
source share