-
Notifications
You must be signed in to change notification settings - Fork 1
/
method.go
38 lines (32 loc) · 1 KB
/
method.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
package sip
import "strings"
type Method string
// Determine if the given method equals some other given method.
// This is syntactic sugar for case insensitive equality checking.
func (method *Method) Equals(other *Method) bool {
if method != nil && other != nil {
return strings.EqualFold(string(*method), string(*other))
} else {
return method == other
}
}
func (method *Method) Is(s string) bool {
return strings.ToLower(string(*method)) == strings.ToLower(s)
}
//String
func (method Method) String() string {
return string(method)
}
// It's nicer to avoid using raw strings to represent methods, so the following standard
// method names are defined here as constants for convenience.
const (
MethodInvite Method = "INVITE"
MethodAck Method = "ACK"
MethodCancel Method = "CANCEL"
MethodBye Method = "BYE"
MethodRegister Method = "REGISTER"
MethodOptions Method = "OPTIONS"
MethodSubscribe Method = "SUBSCRIBE"
MethodNotify Method = "NOTIFY"
MethodRefer Method = "REFER"
)