public void NodeLeft(Address node, DateTime leaveTime)
 {
     HashVector<string, ConnectedClient> deadClients = new HashVector<string, ConnectedClient>();
     lock (_lock)
     {
         foreach (var connectedClient in _connectedClients)
         {
             if (connectedClient.Value.RemoveNode(node) == 0)
             {
                 deadClients.Add(connectedClient.Key, connectedClient.Value);
             }
         }
         if (deadClients.Count > 0)
         {
             foreach (var deadClient in deadClients)
             {
                 _connectedClients.Remove(deadClient.Key);
                 foreach (var notificationSpecification in _specifications)
                 {
                     var task = new DeadClientNotificationTask(this, deadClient.Key, leaveTime,
                         notificationSpecification.Value, deadClient.Value.Info);
                     notificationSpecification.Value.AddNotificationSpecificationTask(deadClient.Key, task);
                     s_scheduler.AddTask(task);
                 }
             }
         }
     }
 }
Exemple #2
0
        private void CreateNewDeadClientFinalizer(string clientId, DateTime time)
        {
            DeadClientNotificationTask finalizer = new DeadClientNotificationTask(this, clientId, time);

            lock (syncRoot)
                _deadClientFinalizers.Add(clientId, finalizer);

            s_scheduler.AddTask(finalizer);
        }
 public void AddNotificationSpecificationTask(string clientId, DeadClientNotificationTask task)
 {
     lock (this)
     {
         if (_tasks != null)
         {
             if (!_tasks.ContainsKey(clientId))
                 _tasks.Add(clientId, task);
         }
     }
 }
 public DeadClientNotificationTask GetNotificationSpecificationTask(string clientId)
 {
     DeadClientNotificationTask task = null;
     lock (this)
     {
         if (_tasks != null)
         {
             _tasks.TryGetValue(clientId, out task);
         }
         return task;
     }
 }
        private void ClientDisconnectedInternal(string clientId, Address node, DateTime disconnectTime)
        {
            ConnectedClient client;

            if (_connectedClients.TryGetValue(clientId, out client))
            {
                if (client.RemoveNode(node) == 0)
                {
                    _connectedClients.Remove(clientId);
                    foreach (var notificationSpecification in _specifications)
                    {
                        if (!notificationSpecification.Value.ContainsKey(clientId))
                        {
                            var task = new DeadClientNotificationTask(this, clientId, disconnectTime,
                                                                      notificationSpecification.Value, client.Info);
                            notificationSpecification.Value.AddNotificationSpecificationTask(clientId, task);
                            s_scheduler.AddTask(task);
                        }
                    }
                }
            }
        }