@@ -46,28 +46,28 @@ type Client struct {
46
46
47
47
// ClientProperties contains a limited set of the mqtt v5 properties specific to a client connection.
48
48
type ClientProperties struct {
49
- AuthenticationData []byte `json:"authenticationData"`
50
- User []packets.UserProperty `json:"user"`
51
- AuthenticationMethod string `json:"authenticationMethod"`
52
- SessionExpiryInterval uint32 `json:"sessionExpiryInterval"`
53
- MaximumPacketSize uint32 `json:"maximumPacketSize"`
54
- ReceiveMaximum uint16 `json:"receiveMaximum"`
55
- TopicAliasMaximum uint16 `json:"topicAliasMaximum"`
56
- SessionExpiryIntervalFlag bool `json:"sessionExpiryIntervalFlag"`
57
- RequestProblemInfo byte `json:"requestProblemInfo"`
58
- RequestProblemInfoFlag bool `json:"requestProblemInfoFlag"`
59
- RequestResponseInfo byte `json:"requestResponseInfo"`
49
+ AuthenticationData []byte `json:"authenticationData,omitempty "`
50
+ User []packets.UserProperty `json:"user,omitempty "`
51
+ AuthenticationMethod string `json:"authenticationMethod,omitempty "`
52
+ SessionExpiryInterval uint32 `json:"sessionExpiryInterval,omitempty "`
53
+ MaximumPacketSize uint32 `json:"maximumPacketSize,omitempty "`
54
+ ReceiveMaximum uint16 `json:"receiveMaximum,omitempty "`
55
+ TopicAliasMaximum uint16 `json:"topicAliasMaximum,omitempty "`
56
+ SessionExpiryIntervalFlag bool `json:"sessionExpiryIntervalFlag,omitempty "`
57
+ RequestProblemInfo byte `json:"requestProblemInfo,omitempty "`
58
+ RequestProblemInfoFlag bool `json:"requestProblemInfoFlag,omitempty "`
59
+ RequestResponseInfo byte `json:"requestResponseInfo,omitempty "`
60
60
}
61
61
62
62
// ClientWill contains a will message for a client, and limited mqtt v5 properties.
63
63
type ClientWill struct {
64
- Payload []byte `json:"payload"`
65
- User []packets.UserProperty `json:"user"`
66
- TopicName string `json:"topicName"`
67
- Flag uint32 `json:"flag"`
68
- WillDelayInterval uint32 `json:"willDelayInterval"`
69
- Qos byte `json:"qos"`
70
- Retain bool `json:"retain"`
64
+ Payload []byte `json:"payload,omitempty "`
65
+ User []packets.UserProperty `json:"user,omitempty "`
66
+ TopicName string `json:"topicName,omitempty "`
67
+ Flag uint32 `json:"flag,omitempty "`
68
+ WillDelayInterval uint32 `json:"willDelayInterval,omitempty "`
69
+ Qos byte `json:"qos,omitempty "`
70
+ Retain bool `json:"retain,omitempty "`
71
71
}
72
72
73
73
// MarshalBinary encodes the values into a json string.
@@ -85,29 +85,29 @@ func (d *Client) UnmarshalBinary(data []byte) error {
85
85
86
86
// Message is a storable representation of an MQTT message (specifically publish).
87
87
type Message struct {
88
- Properties MessageProperties `json:"properties"` // -
89
- Payload []byte `json:"payload"` // the message payload (if retained)
90
- T string `json:"t"` // the data type
91
- ID string `json:"id" storm:"id"` // the storage key
92
- Origin string `json:"origin"` // the id of the client who sent the message
93
- TopicName string `json:"topic_name"` // the topic the message was sent to (if retained)
94
- FixedHeader packets.FixedHeader `json:"fixedheader"` // the header properties of the message
95
- Created int64 `json:"created"` // the time the message was created in unixtime
96
- Sent int64 `json:"sent"` // the last time the message was sent (for retries) in unixtime (if inflight)
97
- PacketID uint16 `json:"packet_id"` // the unique id of the packet (if inflight)
88
+ Properties MessageProperties `json:"properties"` // -
89
+ Payload []byte `json:"payload"` // the message payload (if retained)
90
+ T string `json:"t,omitempty "` // the data type
91
+ ID string `json:"id,omitempty " storm:"id"` // the storage key
92
+ Origin string `json:"origin,omitempty "` // the id of the client who sent the message
93
+ TopicName string `json:"topic_name,omitempty "` // the topic the message was sent to (if retained)
94
+ FixedHeader packets.FixedHeader `json:"fixedheader"` // the header properties of the message
95
+ Created int64 `json:"created,omitempty "` // the time the message was created in unixtime
96
+ Sent int64 `json:"sent,omitempty "` // the last time the message was sent (for retries) in unixtime (if inflight)
97
+ PacketID uint16 `json:"packet_id,omitempty "` // the unique id of the packet (if inflight)
98
98
}
99
99
100
100
// MessageProperties contains a limited subset of mqtt v5 properties specific to publish messages.
101
101
type MessageProperties struct {
102
- CorrelationData []byte `json:"correlationData"`
103
- SubscriptionIdentifier []int `json:"subscriptionIdentifier"`
104
- User []packets.UserProperty `json:"user"`
105
- ContentType string `json:"contentType"`
106
- ResponseTopic string `json:"responseTopic"`
107
- MessageExpiryInterval uint32 `json:"messageExpiry"`
108
- TopicAlias uint16 `json:"topicAlias"`
109
- PayloadFormat byte `json:"payloadFormat"`
110
- PayloadFormatFlag bool `json:"payloadFormatFlag"`
102
+ CorrelationData []byte `json:"correlationData,omitempty "`
103
+ SubscriptionIdentifier []int `json:"subscriptionIdentifier,omitempty "`
104
+ User []packets.UserProperty `json:"user,omitempty "`
105
+ ContentType string `json:"contentType,omitempty "`
106
+ ResponseTopic string `json:"responseTopic,omitempty "`
107
+ MessageExpiryInterval uint32 `json:"messageExpiry,omitempty "`
108
+ TopicAlias uint16 `json:"topicAlias,omitempty "`
109
+ PayloadFormat byte `json:"payloadFormat,omitempty "`
110
+ PayloadFormatFlag bool `json:"payloadFormatFlag,omitempty "`
111
111
}
112
112
113
113
// MarshalBinary encodes the values into a json string.
@@ -155,15 +155,15 @@ func (d *Message) ToPacket() packets.Packet {
155
155
156
156
// Subscription is a storable representation of an MQTT subscription.
157
157
type Subscription struct {
158
- T string `json:"t"`
159
- ID string `json:"id" storm:"id"`
160
- Client string `json:"client"`
158
+ T string `json:"t,omitempty "`
159
+ ID string `json:"id,omitempty " storm:"id"`
160
+ Client string `json:"client,omitempty "`
161
161
Filter string `json:"filter"`
162
- Identifier int `json:"identifier"`
163
- RetainHandling byte `json:"retain_handling"`
162
+ Identifier int `json:"identifier,omitempty "`
163
+ RetainHandling byte `json:"retain_handling,omitempty "`
164
164
Qos byte `json:"qos"`
165
- RetainAsPublished bool `json:"retain_as_pub"`
166
- NoLocal bool `json:"no_local"`
165
+ RetainAsPublished bool `json:"retain_as_pub,omitempty "`
166
+ NoLocal bool `json:"no_local,omitempty "`
167
167
}
168
168
169
169
// MarshalBinary encodes the values into a json string.
0 commit comments