forked from rainliu/sip
-
Notifications
You must be signed in to change notification settings - Fork 1
/
CSeqParser.go
53 lines (44 loc) · 1011 Bytes
/
CSeqParser.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package parser
import (
"sip/core"
"sip/header"
)
/** SIPParser for CSeq headers.
*/
type CSeqParser struct {
HeaderParser
}
func NewCSeqParser(cseq string) *CSeqParser {
this := &CSeqParser{}
this.HeaderParser.super(cseq)
return this
}
func (this *CSeqParser) super(cseq string) {
this.HeaderParser.super(cseq)
}
func NewCSeqParserFromLexer(lexer core.Lexer) *CSeqParser {
this := &CSeqParser{}
this.HeaderParser.superFromLexer(lexer)
return this
}
func (this *CSeqParser) Parse() (sh header.Header, ParseException error) {
lexer := this.GetLexer()
lexer.Match(TokenTypes_CSEQ)
lexer.SPorHT()
lexer.Match(':')
lexer.SPorHT()
var number int
var method string
if number, ParseException = lexer.Number(); ParseException != nil {
return nil, ParseException
}
lexer.SPorHT()
if method, ParseException = this.Method(); ParseException != nil {
return nil, ParseException
}
//c.SetMethod(m);
lexer.SPorHT()
lexer.Match('\n')
c := header.NewCSeq(number, method)
return c, nil
}