ParseSIPURIRelaxed() public static method

public static ParseSIPURIRelaxed ( string partialURI ) : SIPURI
partialURI string
return SIPURI
示例#1
0
        /// <summary>
        /// Parses a SIP end point from either a serialised SIP end point string, format of:
        /// (udp|tcp|tls|ws|wss):(IPEndpoint)
        /// or from a string that represents a SIP URI.
        /// </summary>
        /// <param name="sipEndPointStr">The string to parse to extract the SIP end point.</param>
        /// <returns>If successful a SIPEndPoint object or null otherwise.</returns>
        public static SIPEndPoint ParseSIPEndPoint(string sipEndPointStr)
        {
            if (sipEndPointStr.IsNullOrBlank())
            {
                return(null);
            }

            if (sipEndPointStr.ToLower().StartsWith("udp:") ||
                sipEndPointStr.ToLower().StartsWith("tcp:") ||
                sipEndPointStr.ToLower().StartsWith("tls:") ||
                sipEndPointStr.ToLower().StartsWith("ws:") ||
                sipEndPointStr.ToLower().StartsWith("wss:"))
            {
                return(ParseSerialisedSIPEndPoint(sipEndPointStr));
            }
            else
            {
                var sipUri      = SIPURI.ParseSIPURIRelaxed(sipEndPointStr);
                var sipEndPoint = sipUri.ToSIPEndPoint();
                if (sipEndPoint != null)
                {
                    sipEndPoint.Scheme = sipUri.Scheme;
                    return(sipEndPoint);
                }
                else
                {
                    return(null);
                }
            }
        }
示例#2
0
            public void GetAsXMLStringUnitTest()
            {
                Console.WriteLine("--> " + System.Reflection.MethodBase.GetCurrentMethod().Name);

                SIPEventPresence presence = new SIPEventPresence(SIPURI.ParseSIPURI("sip:[email protected]"));

                presence.Tuples.Add(new SIPEventPresenceTuple("1234", SIPEventPresenceStateEnum.open, SIPURI.ParseSIPURIRelaxed("*****@*****.**"), 0.8M));

                Console.WriteLine(presence.ToXMLText());

                Console.WriteLine("-----------------------------------------");
            }