forked from eclipse/paho.golang
/
cp_unsuback.go
41 lines (36 loc) · 1.01 KB
/
cp_unsuback.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
package paho
import "github.com/imkos/paho.golang/packets"
type (
// Unsuback is a representation of an MQTT Unsuback packet
Unsuback struct {
Reasons []byte
Properties *UnsubackProperties
}
// UnsubackProperties is a struct of the properties that can be set
// for a Unsuback packet
UnsubackProperties struct {
ReasonString string
User UserProperties
}
)
// Packet returns a packets library Unsuback from the paho Unsuback
// on which it is called
func (u *Unsuback) Packet() *packets.Unsuback {
return &packets.Unsuback{
Reasons: u.Reasons,
Properties: &packets.Properties{
User: u.Properties.User.ToPacketProperties(),
},
}
}
// UnsubackFromPacketUnsuback takes a packets library Unsuback and
// returns a paho library Unsuback
func UnsubackFromPacketUnsuback(u *packets.Unsuback) *Unsuback {
return &Unsuback{
Reasons: u.Reasons,
Properties: &UnsubackProperties{
ReasonString: u.Properties.ReasonString,
User: UserPropertiesFromPacketUser(u.Properties.User),
},
}
}