Exemplo n.º 1
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);
        }
Exemplo n.º 2
0
        public SIPSorceryNotificationClient(ActivityMessageDelegate logActivityMessage, string serverURL, string apiKey)
        {
            LogActivityMessage_External = logActivityMessage;
            m_address = Guid.NewGuid().ToString();
            BasicHttpSecurityMode    securitymode       = (serverURL.StartsWith("https")) ? BasicHttpSecurityMode.Transport : BasicHttpSecurityMode.None;
            SIPSorcerySecurityHeader securityHeader     = new SIPSorcerySecurityHeader(apiKey);
            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;
        }