예제 #1
0
        public void ParseReplacesHeaderUriUnitTest()
        {
            logger.LogDebug("--> " + System.Reflection.MethodBase.GetCurrentMethod().Name);
            logger.BeginScope(System.Reflection.MethodBase.GetCurrentMethod().Name);

            SIPURI referToUri = SIPURI.ParseSIPURI("sip:[email protected]?Replaces=84929ZTg0Zjk1Y2UyM2Q1OWJjYWNlZmYyYTI0Njg1YjgwMzI%3Bto-tag%3D8787f9cc94bb4bb19c089af17e5a94f7%3Bfrom-tag%3Dc2b89404");

            Assert.NotNull(referToUri);
            Assert.Equal("sip:[email protected]", referToUri.ToParameterlessString());

            logger.LogDebug("-----------------------------------------");
        }
        private int GetUpdatedExpiry(SIPResponse sipResponse)
        {
            // Find the contact in the list that matches the one being maintained by this agent in order to determine the expiry value.
            int serverExpiry   = m_expiry;
            int headerExpires  = sipResponse.Header.Expires;
            int contactExpires = -1;

            if (sipResponse.Header.Contact != null && sipResponse.Header.Contact.Count > 0)
            {
                if (sipResponse.Header.Contact.Count == 1)
                {
                    contactExpires = sipResponse.Header.Contact[0].Expires;
                }
                else
                {
                    foreach (SIPContactHeader contactHeader in sipResponse.Header.Contact)
                    {
                        if (contactHeader.ContactURI.ToParameterlessString() == m_contactURI.ToParameterlessString())
                        {
                            contactExpires = contactHeader.Expires;
                            break;
                        }
                    }
                }
            }

            if (contactExpires != -1)
            {
                serverExpiry = contactExpires;
            }
            else if (headerExpires != -1)
            {
                serverExpiry = headerExpires;
            }

            if (serverExpiry < REGISTER_MINIMUM_EXPIRY)
            {
                // Make sure we don't do a 3CX and send registration floods.
                return(REGISTER_MINIMUM_EXPIRY);
            }
            else if (serverExpiry > MAX_EXPIRY)
            {
                return(MAX_EXPIRY);
            }
            else
            {
                return(serverExpiry);
            }
        }
예제 #3
0
        public string ToParameterlessString()
        {
            try
            {
                string userFieldStr = null;

                if (Name != null)
                {
                    userFieldStr = "\"" + Name + "\" ";
                }

                userFieldStr += "<" + URI.ToParameterlessString() + ">";

                return(userFieldStr);
            }
            catch (Exception excp)
            {
                Logger.Logger.Error("Exception SIPUserField ToParameterlessString. ->" + excp.Message);
                throw;
            }
        }