Пример #1
0
        public SIPDialogue(
            string callId,
            SIPRouteSet routeSet,
            SIPUserField localUser,
            SIPUserField remoteUser,
            int cseq,
            SIPURI remoteTarget,
            string localTag,
            string remoteTag,
            Guid cdrId,
            string owner,
            string adminMemberId,
            string sdp,
            string remoteSDP)
        {
            Id = Guid.NewGuid();

            CallId          = callId;
            RouteSet        = routeSet;
            LocalUserField  = localUser;
            LocalTag        = localTag;
            RemoteUserField = remoteUser;
            RemoteTag       = remoteTag;
            CSeq            = cseq;
            RemoteTarget    = remoteTarget;
            CDRId           = cdrId;
            Owner           = owner;
            AdminMemberId   = adminMemberId;
            SDP             = sdp;
            RemoteSDP       = remoteSDP;
            Inserted        = DateTimeOffset.UtcNow;
            Direction       = SIPCallDirection.None;
        }
Пример #2
0
        public SIPUserField CopyOf()
        {
            SIPUserField copy = new SIPUserField();

            copy.Name       = Name;
            copy.URI        = URI.CopyOf();
            copy.Parameters = Parameters.CopyOf();

            return(copy);
        }
Пример #3
0
        public static SIPUserField ParseSIPUserField(string userFieldStr)
        {
            if (userFieldStr.IsNullOrBlank())
            {
                throw new ArgumentException("A SIPUserField cannot be parsed from an empty string.");
            }

            SIPUserField userField     = new SIPUserField();
            string       trimUserField = userFieldStr.Trim();

            int position = trimUserField.IndexOf('<');

            if (position == -1)
            {
                // Treat the field as a URI only, except that all parameters are Header parameters and not URI parameters
                // (RFC3261 section 20.39 which refers to 20.10 for parsing rules).
                string uriStr         = trimUserField;
                int    paramDelimPosn = trimUserField.IndexOf(PARAM_TAG_DELIMITER);

                if (paramDelimPosn != -1)
                {
                    string paramStr = trimUserField.Substring(paramDelimPosn + 1).Trim();
                    userField.Parameters = new SIPParameters(paramStr, PARAM_TAG_DELIMITER);
                    uriStr = trimUserField.Substring(0, paramDelimPosn);
                }

                userField.URI = SIPURI.ParseSIPURI(uriStr);
            }
            else
            {
                if (position > 0)
                {
                    userField.Name = trimUserField.Substring(0, position).Trim().Trim('"');
                    trimUserField  = trimUserField.Substring(position, trimUserField.Length - position);
                }

                int addrSpecLen = trimUserField.Length;
                position = trimUserField.IndexOf('>');
                if (position != -1)
                {
                    addrSpecLen = trimUserField.Length - 1;
                    if (position != -1)
                    {
                        addrSpecLen = position - 1;

                        string paramStr = trimUserField.Substring(position + 1).Trim();
                        userField.Parameters = new SIPParameters(paramStr, PARAM_TAG_DELIMITER);
                    }

                    string addrSpec = trimUserField.Substring(1, addrSpecLen);

                    userField.URI = SIPURI.ParseSIPURI(addrSpec);
                }
                else
                {
                    throw new SIPValidationException(SIPValidationFieldsEnum.ContactHeader,
                                                     "A SIPUserField was missing the right quote, " + userFieldStr + ".");
                }
            }

            return(userField);
        }