Inheritance: System.ServiceModel.Channels.MessageHeader
        public void CloseConnection()
        {
            PullNotificationHeader notificationHeader = PullNotificationHeader.ParseHeader(OperationContext.Current);

            if (notificationHeader != null)
            {
                GetPublisher().CloseConnection(notificationHeader.Address);
            }
            else
            {
                throw new ApplicationException("The notification header was missing from the Close request.");
            }
        }
        public Dictionary <string, List <string> > GetNotifications()
        {
            PullNotificationHeader notificationHeader = PullNotificationHeader.ParseHeader(OperationContext.Current);

            if (notificationHeader != null)
            {
                return(GetNotificationsForAddress(notificationHeader.Address));
            }
            else
            {
                throw new ApplicationException("The GetNotifications request was missing a required " + PullNotificationHeader.NOTIFICATION_HEADER_NAME + " header.");
            }
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="filter"></param>
        /// <returns>If the set filter is successful a session ID otherwise null.</returns>
        public string Subscribe(string subject, string filter)
        {
            PullNotificationHeader notificationHeader = PullNotificationHeader.ParseHeader(OperationContext.Current);

            if (notificationHeader != null)
            {
                if (subject == "ControlClient")
                {
                    subject = "Console";
                }

                return(SubscribeForAddress(subject, filter, notificationHeader.Address));
            }
            else
            {
                throw new ApplicationException("The notification header was missing from the SetFilter request.");
            }
        }
        public SIPSorceryNotificationClient(ActivityMessageDelegate logActivityMessage, string serverURL, string authid)
        {
            LogActivityMessage_External = logActivityMessage;
            m_address = Guid.NewGuid().ToString();
            BasicHttpSecurityMode securitymode = (serverURL.StartsWith("https")) ? BasicHttpSecurityMode.Transport : BasicHttpSecurityMode.None;
            SIPSorcerySecurityHeader securityHeader = new SIPSorcerySecurityHeader(authid);
            PullNotificationHeader notificationHeader = new PullNotificationHeader(m_address);
            SIPSorceryCustomHeader sipSorceryHeader = new SIPSorceryCustomHeader(new List<MessageHeader>() { securityHeader, notificationHeader });
            BasicHttpCustomHeaderBinding binding = new BasicHttpCustomHeaderBinding(sipSorceryHeader, securitymode);

            EndpointAddress address = new EndpointAddress(serverURL);
            m_notificationClient = new NotificationsClient(binding, address);

            m_notificationClient.IsAliveCompleted += IsAliveCompleted;
            m_notificationClient.GetPollPeriodCompleted += GetPollPeriodCompleted;
            m_notificationClient.SubscribeCompleted += SubscribeCompleted;
            m_notificationClient.GetNotificationsCompleted += GetNotificationsCompleted;
        }
        public void Subscribe(string subject, string filter)
        {
            PollingDuplexHttpSecurityMode securitymode = (m_serverURL.StartsWith("https")) ? PollingDuplexHttpSecurityMode.Transport : PollingDuplexHttpSecurityMode.None;
            SIPSorcerySecurityHeader securityHeader = new SIPSorcerySecurityHeader(m_authID);
            PullNotificationHeader notificationsHeader = new PullNotificationHeader(m_address.ToString());
            SIPSorceryCustomHeader sipSorceryHeader = new SIPSorceryCustomHeader(new List<MessageHeader>() { securityHeader, notificationsHeader });
            PollingDuplexCustomHeaderBinding notifierBinding = new PollingDuplexCustomHeaderBinding(sipSorceryHeader, securitymode) { UseTextEncoding = true };
            m_client = new PubSubClient(notifierBinding, new EndpointAddress(new Uri(m_serverURL)));
            m_client.InnerChannel.Faulted += ChannelFaulted;
            m_client.InnerChannel.Closed += ChannelClosed;
            m_client.NotifyReceived += NotifyReceived;
            m_client.CloseSessionReceived += CloseSessionReceived;
            //DebugMessage_External("Polling Duplex client created, sessionID=" + m_client.InnerChannel.SessionId + ", timeout=" + m_client.InnerChannel.OperationTimeout.TotalSeconds + "s.");

            m_subject = subject;
            m_filter = filter;
            m_client.SubscribeAsync(m_subject, m_filter);
        }