Exemple #1
0
        public override string ToString()
        {
            StringBuilder builder = new StringBuilder();

            builder.AppendLine(this.GetFirstLine());
            foreach (var field in this.headFielders)
            {
                if (field.Name != "L" && !string.IsNullOrEmpty(field.Value))
                {
                    builder.AppendLine(field.ToString());
                }
            }
            string body = this.Body;

            if (this.body.Trim().Length > 0)
            {
                SipHeadField lengthField = new SipHeadField(SipHeadFieldName.ContentLength, Encoding.UTF8.GetByteCount(body).ToString());
                builder.AppendLine(lengthField.ToString());
                builder.AppendLine(Environment.NewLine + body);
            }
            else
            {
                builder.AppendLine(Environment.NewLine + Environment.NewLine);
            }
            return(builder.ToString());
        }
Exemple #2
0
        public static string GetCSeqMethod(SipHeadField field)
        {
            //Q: 2 R
            string raw = field.ToString();

            if (!raw.StartsWith(SipHeadFieldName.CSeq))
            {
                throw new ArgumentException("can't get CSeqMethod from :" + field.Value);
            }
            string[] arr = raw.Split(new char[] { ' ' });
            if (arr.Length > 1)
            {
                return(arr[2]);
            }
            return(string.Empty);
        }