private void ProcessNotification(notificationType notification) { SupervisorMonitoringChannel monitoringChannel = _monitoringChannel; if (!string.IsNullOrEmpty(notification.sessionId) && monitoringChannel != null && notification.sessionId.Equals(monitoringChannel.SessionId)) { monitoringChannel.ProcessNotification(notification); } else { if (notification.agentinfos.Length > 0 || notification.agentsremoved.Length > 0) { lock (_agents) { foreach (agentType notificationAgentinfo in notification.agentinfos) { _agents[notificationAgentinfo.uri] = notificationAgentinfo; } foreach (string uri in notification.agentsremoved) { _agents.Remove(uri); } AgentsChangedEventArgs e = new AgentsChangedEventArgs(notification.agentinfos, notification.agentsremoved); EventHandler <AgentsChangedEventArgs> agentsChangedHandler = AgentsChanged; if (agentsChangedHandler != null) { agentsChangedHandler(this, e); } } } } }
internal void ProcessNotification(notificationType notification) { if (notification.agentinfos.Length > 0 || notification.agentsremoved.Length > 0) { lock (_agents) { foreach (agentType notificationAgentinfo in notification.agentinfos) { _agents[notificationAgentinfo.uri] = notificationAgentinfo; } foreach (string uri in notification.agentsremoved) { _agents.Remove(uri); } } AgentsChangedEventArgs e = new AgentsChangedEventArgs(notification.agentinfos, notification.agentsremoved); EventHandler<AgentsChangedEventArgs> agentsChangedHandler = AgentsChanged; if (agentsChangedHandler != null) { agentsChangedHandler(this, e); } } if (notification.participantinfos.Length > 0 || notification.partcicipantsremoved.Length > 0) { List<participantType> customersUpdated = new List<participantType>(); List<participantType> participantsUpdated = new List<participantType>(); List<string> customersRemoved = new List<string>(); List<string> participantsRemoved = new List<string>(); lock (_participants) { foreach (participantType notificationParticipantinfo in notification.participantinfos) { if (notificationParticipantinfo.iscustomer) { _customers[notificationParticipantinfo.uri] = notificationParticipantinfo; customersUpdated.Add(notificationParticipantinfo); } else { _participants[notificationParticipantinfo.uri] = notificationParticipantinfo; participantsUpdated.Add(notificationParticipantinfo); } } foreach (string uri in notification.partcicipantsremoved) { if (_customers.Remove(uri)) { customersRemoved.Add(uri); } if (_participants.Remove(uri)) { participantsRemoved.Add(uri); } } } if (participantsRemoved.Count > 0 || participantsUpdated.Count > 0) { ParticipantsChangedEventArgs e = new ParticipantsChangedEventArgs(participantsUpdated, participantsRemoved); EventHandler<ParticipantsChangedEventArgs> participantsChangedHandler = ParticipantsChanged; if (participantsChangedHandler != null) { participantsChangedHandler(this, e); } } if (customersRemoved.Count > 0 || customersUpdated.Count > 0) { ParticipantsChangedEventArgs e = new ParticipantsChangedEventArgs(customersUpdated, customersRemoved); EventHandler<ParticipantsChangedEventArgs> customersChangedHandler = CustomersChanged; if (customersChangedHandler != null) { customersChangedHandler(this, e); } } } }