Exemplo n.º 1
0
        public override SipCSeqHeader Parse(StringReader r)
        {
            SipCSeqHeader header = new SipCSeqHeader();

            var word = r.ReadWord();

            IfNullThrowParseExceptionInvalidFormat(word);

            word = word.Trim();

            IfFalseThrowParseException(ParseUtil.IsInteger(word), ExceptionMessage.InvalidFormat);

            header.Sequence = int.Parse(word);

            word = r.ReadWord();

            IfNullOrEmptyThrowParseExceptionInvalidFormat(word);

            IfFalseThrowParseException(SipMethods.IsMethod(word), ExceptionMessage.SipMethodNotSupprted);

            IfFalseThrowParseException(string.IsNullOrWhiteSpace(r.ReadToEnd()), ExceptionMessage.InvalidFormat);

            header.Command = word.Trim();

            return(header);
        }
Exemplo n.º 2
0
        public override SipMaxForwardsHeader Parse(StringReader r)
        {
            var header = new SipMaxForwardsHeader();

            var word = r.ReadWord();

            IfFalseThrowParseException(ParseUtil.IsInteger(word), ExceptionMessage.InvalidFormat);

            header.Value = int.Parse(word);

            IfFalseThrowParseException(string.IsNullOrWhiteSpace(r.ReadToEnd()), ExceptionMessage.InvalidFormat);

            return(header);
        }
Exemplo n.º 3
0
        public override SipStatusLine Parse(StringReader r)
        {
            string[] splitted = r.OriginalString.Split(new char[] { ' ' }, 3);

            IfFalseThrowParseException(splitted.Length == 3, ExceptionMessage.InvalidStatusLineFormat);
            IfFalseThrowParseException(splitted[0].Equals(SipConstants.SipTwoZeroString), ExceptionMessage.InvalidSipVersion);
            IfFalseThrowParseException(ParseUtil.IsInteger(splitted[1]), ExceptionMessage.InvalidFormat);
            IfNullOrEmptyThrowParseExceptionInvalidFormat(splitted[2]);
            IfFalseThrowParseException(splitted[2].Length <= 250, "The 'ReasonPhrase' field of the 'StatusLine' can not be longer than 250 characters");

            var result = new SipStatusLine();

            result.Version      = SipConstants.SipTwoZeroString;
            result.StatusCode   = int.Parse(splitted[1]);
            result.ReasonPhrase = splitted[2];

            return(result);
        }