示例#1
0
 public void RemoveEvent(Guid listenerGuid, Guid guid)
 {
     lock (Sessions)
     {
         GXSession session = GetSession(listenerGuid);
         if (session != null)
         {
             //Check that we are not listen this client.
             foreach (GXEvent it in session.NotifyClients)
             {
                 if (it.DataCollectorGuid == guid)
                 {
                     session.NotifyClients.Remove(it);
                     break;
                 }
             }
             //Remove collection if empty.
             if (session.NotifyClients.Count == 0)
             {
                 session.Received.Set();
                 Sessions.Remove(session);
             }
         }
         else
         {
             System.Diagnostics.Debug.WriteLine("RemoveEvent failed. Event not found.");
         }
     }
 }
示例#2
0
 /// <summary>
 /// TODO: Remove event if not called after a hour.
 /// </summary>
 /// <param name="listenerGuid"></param>
 /// <param name="e"></param>
 public void AddEvent(Guid listenerGuid, GXEvent e)
 {
     lock (Sessions)
     {
         GXSession session = GetSession(listenerGuid);
         if (session != null)
         {
             //Check that we are not listen this client.
             foreach (GXEvent e1 in session.NotifyClients)
             {
                 if (e1.Instance == e.Instance)
                 {
                     session.NotifyClients.Remove(e1);
                     break;
                 }
             }
             session.NotifyClients.Add(e);
         }
         else
         {
             GXSession ses = new GXSession(e.Instance);
             Sessions.Add(ses);
             ses.NotifyClients.Add(e);
         }
     }
 }