예제 #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 SIPDialogue(
            string callId,
            SIPRouteSet routeSet,
            SIPUserField localUser,
            SIPUserField remoteUser,
            int cseq,
            SIPURI remoteTarget,
            string localTag,
            string remoteTag,
            Guid cdrId,
            string sdp,
            string remoteSDP,
            SIPEndPoint remoteEndPoint)
        {
            Id = Guid.NewGuid();

            CallId            = callId;
            RouteSet          = routeSet;
            LocalUserField    = localUser;
            LocalTag          = localTag;
            RemoteUserField   = remoteUser;
            RemoteTag         = remoteTag;
            CSeq              = cseq;
            RemoteTarget      = remoteTarget;
            CDRId             = cdrId;
            SDP               = sdp;
            RemoteSDP         = remoteSDP;
            Inserted          = DateTime.UtcNow;
            Direction         = SIPCallDirection.None;
            RemoteSIPEndPoint = remoteEndPoint?.CopyOf();
        }
예제 #3
0
        public static SIPUserField ParseSIPUserField(string userFieldStr)
        {
            if (string.IsNullOrWhiteSpace(userFieldStr))
            {
                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 = 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);
        }
예제 #4
0
        public SIPUserField CopyOf()
        {
            SIPUserField copy = new SIPUserField();

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

            return(copy);
        }
예제 #5
0
 public SIPToHeader(string toName, SIPURI toURI, string toTag)
 {
     m_userField = new SIPUserField(toName, toURI, null);
     ToTag = toTag;
 }
예제 #6
0
 public SIPFromHeader(string fromName, SIPURI fromURI, string fromTag)
 {
     m_userField = new SIPUserField(fromName, fromURI, null);
     FromTag = fromTag;
 }
예제 #7
0
 public SIPRoute(SIPURI uri, bool looseRouter)
 {
     m_userField = new SIPUserField();
     m_userField.URI = uri;
     this.IsStrictRouter = !looseRouter;
 }
예제 #8
0
 public SIPRoute(SIPURI uri)
 {
     m_userField = new SIPUserField();
     m_userField.URI = uri;
 }
예제 #9
0
        public SIPRoute(string host, bool looseRouter)
        {
            if (host.IsNullOrBlank())
            {
                throw new SIPValidationException(SIPValidationFieldsEnum.RouteHeader, "Cannot create a Route from an blank string.");
            }

            m_userField = SIPUserField.ParseSIPUserField(host);
            this.IsStrictRouter = !looseRouter;
        }
예제 #10
0
 public SIPContactHeader(SIPUserField contactUserField)
 {
     m_userField = contactUserField;
 }
예제 #11
0
 public SIPContactHeader(string contactName, SIPURI contactURI)
 {
     m_userField = new SIPUserField(contactName, contactURI, null);
 }
예제 #12
0
        public SIPUserField CopyOf()
        {
            SIPUserField copy = new SIPUserField();
            copy.Name = Name;
            copy.URI = URI.CopyOf();
            copy.Parameters = Parameters.CopyOf();

            return copy;
        }
예제 #13
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;
        }
예제 #14
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;
        }