forked from rainliu/sip
-
Notifications
You must be signed in to change notification settings - Fork 1
/
CallIdParser.go
56 lines (44 loc) · 1.06 KB
/
CallIdParser.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
54
55
56
package parser
import (
"sip/core"
"sip/header"
"strings"
)
/** SIPParser for CALL ID header.
*/
type CallIDParser struct {
HeaderParser
}
/** Creates new CallIDParser
* @param String callID message to parse to set
*/
func NewCallIDParser(callId string) *CallIDParser {
this := &CallIDParser{}
this.HeaderParser.super(callId)
return this
}
func (this *CallIDParser) super(callId string) {
this.HeaderParser.super(callId)
}
/** Constructor
* @param lexer to set
*/
func NewCallIDParserFromLexer(lexer core.Lexer) *CallIDParser {
this := &CallIDParser{}
this.HeaderParser.superFromLexer(lexer)
return this
}
/** parse the String message
* @return Header (CallID object)
* @throws ParseException if the message does not respect the spec.
*/
func (this *CallIDParser) Parse() (sh header.Header, ParseException error) {
lexer := this.GetLexer()
lexer.Match(TokenTypes_CALL_ID)
lexer.SPorHT()
lexer.Match(':')
lexer.SPorHT()
rest := strings.TrimSpace(lexer.GetRest())
callID, ParseException := header.NewCallID(rest)
return callID, ParseException
}