Exemple #1
0
        internal static PollingDuplexSession FindHeader(MessageHeaders headers)
        {
            PollingDuplexSession info = null;

            try
            {
                int headerIndex = headers.FindHeader("Duplex", "http://schemas.microsoft.com/2008/04/netduplex");
                if (headerIndex != -1)
                {
                    info = ReadHeaderValue(headers.GetReaderAtHeader(headerIndex));
                }
            }
            catch (XmlException)
            {
            }
            return(info);
        }
        public void Subscribe(string topic)
        {
            //SIPNotifierClientSession notifierSession = null;
            string sessionID = null;

            try
            {
                PollingDuplexSession session = OperationContext.Current.GetPollingDuplexSession();
                sessionID = session.SessionId;

                /*lock (m_notifierSessions)
                 * {
                 *  if (m_notifierSessions.ContainsKey(session.Address))
                 *  {
                 *      notifierSession = m_notifierSessions[session.Address];
                 *      if (notifierSession.HasErroredSession)
                 *      {
                 *          // Not taking any further action for errored session.
                 *          notifierSession = null;
                 *          logger.Debug("Not taking any further action on errored connection " + session.Address + ".");
                 *      }
                 *      else
                 *      {
                 *          notifierSession.AddSessionID(session.SessionId);
                 *      }
                 *  }
                 *  else
                 *  {
                 *      notifierSession = new SIPNotifierClientSession(session);
                 *      m_notifierSessions.Add(session.Address, notifierSession);
                 *  }
                 * }*/

                Customer customer = AuthoriseRequest();
                if (customer != null)
                {
                    string customerUsername = customer.CustomerUsername;
                    string adminId          = customer.AdminId;

                    logger.Debug("SIPNotifierService received Subscribe request for customer=" + customerUsername + ", adminid=" + adminId + " and filter=" + topic + ".");

                    string subscribeError = null;

                    GetPublisher().Subscribe(customerUsername, adminId, session.Address, session.SessionId, null, topic, 0, null, out subscribeError);

                    if (subscribeError != null)
                    {
                        throw new ApplicationException(subscribeError);
                    }
                }
            }
            catch (Exception excp)
            {
                logger.Error("Exception SIPNotifierService Subscribe. " + excp);

                /*try
                 * {
                 *  if (notifierSession != null && sessionID != null)
                 *  {
                 *      notifierSession.SetSessionError(sessionID, excp.Message);
                 *
                 *      if (m_pendingNotifications.ContainsKey(notifierSession.Address))
                 *      {
                 *          m_pendingNotifications[notifierSession.Address].NotificationsReady();
                 *      }
                 *  }
                 * }
                 * catch (Exception failedSubExcp)
                 * {
                 *  logger.Error("Exception SIPNotifierService Subscribe processing failed subscription. " + failedSubExcp.Message);
                 * }*/
            }
        }