-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
doc_test.go
65 lines (51 loc) · 1007 Bytes
/
doc_test.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
57
58
59
60
61
62
63
64
65
package mq
import (
"bytes"
"strings"
)
func DocumentFlags(p Packet) string {
var buf bytes.Buffer
name := p.String()
i := strings.Index(name, " ")
buf.WriteString(strings.Repeat(" ", i+1))
switch p.(type) {
case *Connect:
buf.WriteString(`3210 76543210 ProtocolVersion ClientID KeepAlive Size
3-0 reserved
7 u User Name Flag
6 p Password Flag
5 r Will Retain
4 2|! Will QoS
3 1|! Will QoS
2 w Will Flag
1 s Clean Start
0 reserved
`)
case *ConnAck:
buf.WriteString(`3210 76543210 AssignedClientID Size [ReasonCode and ReasonString if error]
3-0 reserved
7-1 reserved
0 s Session present
`)
case *PubAck:
buf.WriteString(`3210 PacketID ReasonString Size [reason text]
3-0 reserved
`)
case *SubAck:
buf.WriteString(`3210 PacketID Size
3-0 reserved
`)
case *Publish:
buf.WriteString(`3210 PacketID Topic [CorrelationData] Size
3 d Duplicate
2 2|! QoS
1 1|! QoS
0 r Retain
`)
default:
buf.WriteString(`3210 Size
3-0 reserved
`)
}
return buf.String()
}