Esempio n. 1
0
        public void Close()
        {
            try
            {
                if (m_client != null)
                {
                    try
                    {
                        m_client.SubscribeAsync(m_subject, null);
                    }
                    catch { }

                    m_client.CloseAsync();
                    m_client = null;

                    if (Closed != null)
                    {
                        Closed();
                    }
                }
            }
            catch
            {
                //LogActivityMessage(MessageLevelsEnum.Error, "Exception closing notification channel. " + excp.Message);
            }
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
 public void Initialize(PubSubClient proxy)
 {
     this.proxy = proxy;
 }