Ejemplo n.º 1
0
        private void GetNotificationsCompleted(object sender, GetNotificationsCompletedEventArgs e)
        {
            if (e.Error == null)
            {
                if (m_pollRequestHadError)
                {
                    m_pollRequestHadError = false;

                    if (StatusChanged != null)
                    {
                        StatusChanged(ServiceConnectionStatesEnum.Ok, null);
                    }
                }

                if (e.Result != null && e.Result.Count > 0)
                {
                    foreach (KeyValuePair <string, List <string> > notificationSet in e.Result)
                    {
                        if (notificationSet.Key == m_machineEventSessionID && MachineEventReceived != null)
                        {
                            foreach (string machineEventStr in notificationSet.Value)
                            {
                                MachineEventReceived(SIPMonitorMachineEvent.ParseMachineEventCSV(machineEventStr));
                            }
                        }
                        else if (notificationSet.Key == m_controlEventSessionID && ControlEventReceived != null)
                        {
                            foreach (string controlEventStr in notificationSet.Value)
                            {
                                ControlEventReceived(controlEventStr);
                            }
                        }
                    }
                }
            }
            else
            {
                if (!m_pollRequestHadError)
                {
                    m_pollRequestHadError = true;
                    //LogActivityMessage_External(MessageLevelsEnum.Warn, "Error retrieving notifications. " + e.Error.Message);

                    if (StatusChanged != null)
                    {
                        StatusChanged(ServiceConnectionStatesEnum.Error, "Error retrieving notifications. " + e.Error.Message);
                    }
                }
            }
        }
        private bool MonitorEventAvailable(SIPMonitorEvent sipMonitorEvent)
        {
            try
            {
                SIPMonitorMachineEvent machineEvent = sipMonitorEvent as SIPMonitorMachineEvent;

                if (machineEvent != null && !machineEvent.SessionID.IsNullOrBlank() && m_subscriptions.ContainsKey(machineEvent.SessionID))
                {
                    SIPEventSubscription subscription = m_subscriptions[machineEvent.SessionID];

                    lock (subscription)
                    {
                        string resourceURI = (machineEvent.ResourceURI != null) ? machineEvent.ResourceURI.ToString() : null;

                        //logger.Debug("NotifierSubscriptionsManager received new " + machineEvent.MachineEventType + ", resource ID=" + machineEvent.ResourceID + ", resource URI=" + resourceURI + ".");

                        //MonitorLogEvent_External(new SIPMonitorConsoleEvent(SIPMonitorServerTypesEnum.Notifier, SIPMonitorEventTypesEnum.Monitor, "NotifierSubscriptionsManager received new " + machineEvent.MachineEventType + ", resource ID=" + machineEvent.ResourceID + ", resource URI=" + resourceURI + ".", subscription.SubscriptionDialogue.Owner));

                        if (subscription.AddMonitorEvent(machineEvent))
                        {
                            SendNotifyRequestForSubscription(subscription);
                        }

                        //logger.Debug("NotifierSubscriptionsManager completed " + machineEvent.MachineEventType + ", resource ID=" + machineEvent.ResourceID + ", resource URI=" + resourceURI + ".");
                    }

                    return(true);
                }

                return(false);
            }
            catch (Exception excp)
            {
                logger.Error("Exception NotifierSubscriptionsManager MonitorEventAvailable. " + excp.Message);
                return(false);
            }
        }
Ejemplo n.º 3
0
 public static void HandleMonitorEvent(Action <SIPMonitorMachineEvent> action, SIPMonitorMachineEvent monitorEvent)
 {
     if (Deployment.Current.Dispatcher.CheckAccess())
     {
         action(monitorEvent);
     }
     else
     {
         Deployment.Current.Dispatcher.BeginInvoke(action, monitorEvent);
     }
 }