Opc.Ua.Com.Server.ComAe2Subscription.OnEventNotification C# (CSharp) Method

OnEventNotification() private method

private OnEventNotification ( Subscription subscription, EventNotificationList notification, IList stringTable ) : void
subscription Subscription
notification EventNotificationList
stringTable IList
return void
        private void OnEventNotification(Subscription subscription, EventNotificationList notification, IList<string> stringTable)
        {
            try
            {
                // check if disposed.
                if (m_disposed)
                {
                    return;
                }

                // check if session still active.
                Session session = m_server.Session;

                if (session == null || !session.Connected)
                {
                    return;
                }

                // check if events are being reported.
                if (m_callback == null)
                {
                    return;
                }

                lock (m_lock)
                {
                    foreach (EventFieldList e in notification.Events)
                    {
                        // translate the notification and send the response.
                        AeEvent e2 = m_filter.TranslateNotification(m_server.Session, e);

                        if (e2 != null)
                        {
                            // check if refresh has started.
                            if (e2.EventType == Opc.Ua.ObjectTypeIds.RefreshStartEventType)
                            {
                                m_refreshInProgress = true;
                                continue;
                            }

                            // check if refresh has ended.
                            if (e2.EventType == Opc.Ua.ObjectTypeIds.RefreshEndEventType)
                            {
                                m_refreshInProgress = false;

                                // turn off publishing if the subscription is not active,
                                if (!Active)
                                {
                                    m_subscription.SetPublishingMode(false);
                                    List<MonitoredItem> itemsToUpdate = new List<MonitoredItem>(m_notifiers.Values);
                                    m_subscription.SetMonitoringMode(MonitoringMode.Disabled, itemsToUpdate);
                                }

                                if (m_refreshQueue != null)
                                {
                                    ThreadPool.QueueUserWorkItem(DoRefresh, m_refreshQueue);
                                }

                                continue;
                            }

                            // cache any conditions requiring acknowledgement.
                            m_conditionManager.ProcessEvent(e2);

                            // queue on refresh.
                            if (m_refreshInProgress)
                            {
                                if (m_refreshQueue != null)
                                {
                                    m_refreshQueue.Enqueue(e2);
                                }

                                continue;
                            }

                            // queue the event.
                            if (Active)
                            {
                                lock (m_queue)
                                {
                                    m_queue.Enqueue(e2);
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception exception)
            {
                Utils.Trace(exception, "Error processing event callback.");
            }
        }