Exemple #1
0
 internal IEnumerable<Guid> FindInterestedSubscribers(TypeOfInterest toi)
 {
     lock (_connections)
     {
         return _connections
             .Where(kvp => kvp.Value.Tois.Contains(toi))
             .Select(kvp => kvp.Value.Id).Distinct();
     }
 }
        // GET api/values
        public async Task <IHttpActionResult> Fire([FromUri] TypeOfInterest toi)
        {
            var subscribers = UpdatesHub.FindInterestedSubscribers(toi);

            if (subscribers.Any())
            {
                var hub = _connectionManager.GetHubContext <UpdatesHub>();
                foreach (Guid id in subscribers)
                {
                    IClientProxy proxy = hub.Clients.Group(id.ToString());
                    await proxy.Invoke(nameof(IClient.Updated), toi);
                }
            }
            //await hub.Clients.All.OnUpdated(toi);
            return(Ok());
        }
Exemple #3
0
 private static void OnUpdated(TypeOfInterest toi)
 {
     Console.WriteLine($"Changed objects: " + toi.ToString());
 }
Exemple #4
0
 public void OnUpdated(TypeOfInterest toi)
 {
     Clients.All.Updated(toi);
 }
Exemple #5
0
 public static IEnumerable <Guid> FindInterestedSubscribers(TypeOfInterest toi)
 {
     return(_connectionFilters.FindInterestedSubscribers(toi));
 }