Beispiel #1
0
 public void SendSubscriptionUpdate(BaseSubscription subscription, SubscriptionUpdateBase subsUpdates)
 {
     foreach (var connection in connections)
     {
         Task.Factory.StartNew(async() => await SendSubscriptionUpdate(subscription, subsUpdates, connection.Value));
     }
 }
        public async Task SendSubscriptionUpdate(BaseSubscription baseSubscription, SubscriptionUpdateBase update)
        {
            if (Subscriptions.TryGetValue(baseSubscription, out var lastUpdate))
            {
                var @lock = locks.GetOrAdd(baseSubscription, (_) => new SemaphoreSlim(1));
                await @lock.WaitAsync();

                try
                {
                    var updateOfInterest = update.GetUpdateForDate(lastUpdate);
                    if (updateOfInterest == null)
                    {
                        return;
                    }
                    Subscriptions[baseSubscription] = updateOfInterest.UpdateDate;
                    await SendMessage(updateOfInterest);
                }
                finally
                {
                    @lock.Release();
                }
            }
        }
Beispiel #3
0
 async Task SendSubscriptionUpdate(BaseSubscription subscription, SubscriptionUpdateBase update, InfoWebSocketConnection connection)
 {
     await connection.SendSubscriptionUpdate(subscription, update);
 }