Documentation ¶
Index ¶
- Variables
- func BoolToByte(b bool) *byte
- func Byte(b byte) *byte
- func Uint16(u uint16) *uint16
- func Uint32(u uint32) *uint32
- type Auth
- type AuthProperties
- type AuthResponse
- type Auther
- type CPContext
- type Client
- func (c *Client) Ack(pb *Publish) error
- func (c *Client) Authenticate(ctx context.Context, a *Auth) (*AuthResponse, error)
- func (c *Client) Connect(ctx context.Context, cp *Connect) (*Connack, error)
- func (c *Client) Disconnect(d *Disconnect) error
- func (c *Client) Publish(ctx context.Context, p *Publish) (*PublishResponse, error)
- func (c *Client) SetDebugLogger(l Logger)
- func (c *Client) SetErrorLogger(l Logger)
- func (c *Client) Subscribe(ctx context.Context, s *Subscribe) (*Suback, error)
- func (c *Client) Unsubscribe(ctx context.Context, u *Unsubscribe) (*Unsuback, error)
- type ClientConfig
- type CommsProperties
- type Connack
- type ConnackProperties
- type Connect
- type ConnectProperties
- type Disconnect
- type DisconnectProperties
- type Logger
- type MIDService
- type MIDs
- type MQTTVersion
- type MemoryPersistence
- func (m *MemoryPersistence) All() []packets.ControlPacket
- func (m *MemoryPersistence) Close()
- func (m *MemoryPersistence) Delete(id uint16)
- func (m *MemoryPersistence) Get(id uint16) packets.ControlPacket
- func (m *MemoryPersistence) Open()
- func (m *MemoryPersistence) Put(id uint16, cp packets.ControlPacket)
- func (m *MemoryPersistence) Reset()
- type MessageHandler
- type NOOPLogger
- type Persistence
- type PingFailHandler
- type PingHandler
- type Pinger
- type Publish
- type PublishProperties
- type PublishResponse
- type PublishResponseProperties
- type Router
- type SingleHandlerRouter
- type StandardRouter
- type Suback
- type SubackProperties
- type Subscribe
- type SubscribeOptions
- type SubscribeProperties
- type Unsuback
- type UnsubackProperties
- type Unsubscribe
- type UnsubscribeProperties
- type UserProperties
- type UserProperty
- type WillMessage
- type WillProperties
Constants ¶
This section is empty.
Variables ¶
var (
ErrManualAcknowledgmentDisabled = errors.New("manual acknowledgments disabled")
)
var (
ErrPacketNotFound = errors.New("packet not found")
)
var ErrorMidsExhausted = errors.New("all message ids in use")
ErrorMidsExhausted is returned from Request() when there are no free message ids to be used.
Functions ¶
func BoolToByte ¶
BoolToByte is a helper function that take a bool and returns a pointer to a byte of value 1 if true or 0 if false
func Byte ¶
Byte is a helper function that take a byte and returns a pointer to a byte of that value
Types ¶
type Auth ¶
type Auth struct { Properties *AuthProperties ReasonCode byte }
Auth is a representation of the MQTT Auth packet
func AuthFromPacketAuth ¶
AuthFromPacketAuth takes a packets library Auth and returns a paho library Auth
func (*Auth) InitProperties ¶
func (a *Auth) InitProperties(p *packets.Properties)
InitProperties is a function that takes a lower level Properties struct and completes the properties of the Auth on which it is called
type AuthProperties ¶
type AuthProperties struct { AuthData []byte AuthMethod string ReasonString string User UserProperties }
AuthProperties is a struct of the properties that can be set for a Auth packet
type AuthResponse ¶
type AuthResponse struct { Properties *AuthProperties ReasonCode byte Success bool }
AuthResponse is a represenation of the response to an Auth packet
func AuthResponseFromPacketAuth ¶
func AuthResponseFromPacketAuth(a *packets.Auth) *AuthResponse
AuthResponseFromPacketAuth takes a packets library Auth and returns a paho library AuthResponse
func AuthResponseFromPacketDisconnect ¶
func AuthResponseFromPacketDisconnect(d *packets.Disconnect) *AuthResponse
AuthResponseFromPacketDisconnect takes a packets library Disconnect and returns a paho library AuthResponse
type Auther ¶
Auther is the interface for something that implements the extended authentication flows in MQTT v5
type CPContext ¶
type CPContext struct { Context context.Context Return chan packets.ControlPacket }
CPContext is the struct that is used to return responses to ControlPackets that have them, eg: the suback to a subscribe. The response packet is send down the Return channel and the Context is used to track timeouts.
type Client ¶
type Client struct { ClientConfig // contains filtered or unexported fields }
Client is the struct representing an MQTT client
func NewClient ¶
func NewClient(conf ClientConfig) *Client
NewClient is used to create a new default instance of an MQTT client. It returns a pointer to the new client instance. The default client uses the provided PingHandler, MessageID and StandardRouter implementations, and a noop Persistence. These should be replaced if desired before the client is connected. client.Conn *MUST* be set to an already connected net.Conn before Connect() is called.
func (*Client) Authenticate ¶
Authenticate is used to initiate a reauthentication of credentials with the server. This function sends the initial Auth packet to start the reauthentication then relies on the client AuthHandler managing any further requests from the server until either a successful Auth packet is passed back, or a Disconnect is received.
func (*Client) Connect ¶
Connect is used to connect the client to a server. It presumes that the Client instance already has a working network connection. The function takes a pre-prepared Connect packet, and uses that to establish an MQTT connection. Assuming the connection completes successfully the rest of the client is initiated and the Connack returned. Otherwise the failure Connack (if there is one) is returned along with an error indicating the reason for the failure to connect.
func (*Client) Disconnect ¶
func (c *Client) Disconnect(d *Disconnect) error
Disconnect is used to send a Disconnect packet to the MQTT server Whether or not the attempt to send the Disconnect packet fails (and if it does this function returns any error) the network connection is closed.
func (*Client) Publish ¶
Publish is used to send a publication to the MQTT server. It is passed a pre-prepared Publish packet and blocks waiting for the appropriate response, or for the timeout to fire. Any response message is returned from the function, along with any errors.
func (*Client) SetDebugLogger ¶
SetDebugLogger takes an instance of the paho Logger interface and sets it to be used by the debug log endpoint
func (*Client) SetErrorLogger ¶
SetErrorLogger takes an instance of the paho Logger interface and sets it to be used by the error log endpoint
func (*Client) Subscribe ¶
Subscribe is used to send a Subscription request to the MQTT server. It is passed a pre-prepared Subscribe packet and blocks waiting for a response Suback, or for the timeout to fire. Any response Suback is returned from the function, along with any errors.
func (*Client) Unsubscribe ¶
Unsubscribe is used to send an Unsubscribe request to the MQTT server. It is passed a pre-prepared Unsubscribe packet and blocks waiting for a response Unsuback, or for the timeout to fire. Any response Unsuback is returned from the function, along with any errors.
type ClientConfig ¶
type ClientConfig struct { ClientID string // Conn is the connection to broker. // BEWARE that most wrapped net.Conn implementations like tls.Conn are // not thread safe for writing. To fix, use packets.NewThreadSafeConn // wrapper or extend the custom net.Conn struct with sync.Locker. Conn net.Conn MIDs MIDService AuthHandler Auther PingHandler Pinger Router Router Persistence Persistence PacketTimeout time.Duration // OnServerDisconnect is called only when a packets.DISCONNECT is received from server OnServerDisconnect func(*Disconnect) // OnClientError is for example called on net.Error OnClientError func(error) // PublishHook allows a user provided function to be called before // a Publish packet is sent allowing it to inspect or modify the // Publish, an example of the utility of this is provided in the // Topic Alias Handler extension which will automatically assign // and use topic alias values rather than topic strings. PublishHook func(*Publish) // EnableManualAcknowledgment is used to control the acknowledgment of packets manually. // BEWARE that the MQTT specs require clients to send acknowledgments in the order in which the corresponding // PUBLISH packets were received. // Consider the following scenario: the client receives packets 1,2,3,4 // If you acknowledge 3 first, no ack is actually sent to the server but it's buffered until also 1 and 2 // are acknowledged. EnableManualAcknowledgment bool // SendAcksInterval is used only when EnableManualAcknowledgment is true // it determines how often the client tries to send a batch of acknowledgments in the right order to the server. SendAcksInterval time.Duration }
ClientConfig are the user configurable options for the client, an instance of this struct is passed into NewClient(), not all options are required to be set, defaults are provided for Persistence, MIDs, PingHandler, PacketTimeout and Router.
type CommsProperties ¶
type CommsProperties struct { MaximumPacketSize uint32 ReceiveMaximum uint16 TopicAliasMaximum uint16 MaximumQoS byte RetainAvailable bool WildcardSubAvailable bool SubIDAvailable bool }
CommsProperties is a struct of the communication properties that may be set by the server in the Connack and that the client needs to be aware of for future subscribes/publishes
type Connack ¶
type Connack struct { Properties *ConnackProperties ReasonCode byte SessionPresent bool }
Connack is a representation of the MQTT Connack packet
func ConnackFromPacketConnack ¶
ConnackFromPacketConnack takes a packets library Connack and returns a paho library Connack
func (*Connack) InitProperties ¶
func (c *Connack) InitProperties(p *packets.Properties)
InitProperties is a function that takes a lower level Properties struct and completes the properties of the Connack on which it is called
type ConnackProperties ¶
type ConnackProperties struct { SessionExpiryInterval *uint32 AuthData []byte AuthMethod string ResponseInfo string ServerReference string ReasonString string AssignedClientID string MaximumPacketSize *uint32 ReceiveMaximum *uint16 TopicAliasMaximum *uint16 ServerKeepAlive *uint16 MaximumQoS *byte User UserProperties WildcardSubAvailable bool SubIDAvailable bool RetainAvailable bool }
ConnackProperties is a struct of the properties that can be set for a Connack packet
type Connect ¶
type Connect struct { Password []byte Username string ClientID string Properties *ConnectProperties WillMessage *WillMessage WillProperties *WillProperties KeepAlive uint16 CleanStart bool UsernameFlag bool PasswordFlag bool }
Connect is a representation of the MQTT Connect packet
func ConnectFromPacketConnect ¶
ConnectFromPacketConnect takes a packets library Connect and returns a paho library Connect
func (*Connect) InitProperties ¶
func (c *Connect) InitProperties(p *packets.Properties)
InitProperties is a function that takes a lower level Properties struct and completes the properties of the Connect on which it is called
func (*Connect) InitWillProperties ¶
func (c *Connect) InitWillProperties(p *packets.Properties)
InitWillProperties is a function that takes a lower level Properties struct and completes the properties of the Will in the Connect on which it is called
type ConnectProperties ¶
type ConnectProperties struct { AuthData []byte AuthMethod string SessionExpiryInterval *uint32 WillDelayInterval *uint32 ReceiveMaximum *uint16 TopicAliasMaximum *uint16 MaximumQOS *byte MaximumPacketSize *uint32 User UserProperties RequestProblemInfo bool RequestResponseInfo bool }
ConnectProperties is a struct of the properties that can be set for a Connect packet
type Disconnect ¶
type Disconnect struct { Properties *DisconnectProperties ReasonCode byte }
Disconnect is a representation of the MQTT Disconnect packet
func DisconnectFromPacketDisconnect ¶
func DisconnectFromPacketDisconnect(p *packets.Disconnect) *Disconnect
DisconnectFromPacketDisconnect takes a packets library Disconnect and returns a paho library Disconnect
func (*Disconnect) InitProperties ¶
func (d *Disconnect) InitProperties(p *packets.Properties)
InitProperties is a function that takes a lower level Properties struct and completes the properties of the Disconnect on which it is called
func (*Disconnect) Packet ¶
func (d *Disconnect) Packet() *packets.Disconnect
Packet returns a packets library Disconnect from the paho Disconnect on which it is called
type DisconnectProperties ¶
type DisconnectProperties struct { ServerReference string ReasonString string SessionExpiryInterval *uint32 User UserProperties }
DisconnectProperties is a struct of the properties that can be set for a Disconnect packet
type Logger ¶
type Logger interface { Println(v ...interface{}) Printf(format string, v ...interface{}) }
Logger interface allows implementations to provide to this package any object that implements the methods defined in it.
type MIDService ¶
type MIDService interface { Request(*CPContext) (uint16, error) Get(uint16) *CPContext Free(uint16) Clear() }
MIDService defines the interface for a struct that handles the relationship between message ids and CPContexts Request() takes a *CPContext and returns a uint16 that is the messageid that should be used by the code that called Request() Get() takes a uint16 that is a messageid and returns the matching *CPContext that the MIDService has associated with that messageid Free() takes a uint16 that is a messageid and instructs the MIDService to mark that messageid as available for reuse Clear() resets the internal state of the MIDService
type MIDs ¶
MIDs is the default MIDService provided by this library. It uses a map of uint16 to *CPContext to track responses to messages with a messageid
func (*MIDs) Clear ¶
func (m *MIDs) Clear()
Clear is the library provided MIDService's implementation of the required interface function()
func (*MIDs) Free ¶
Free is the library provided MIDService's implementation of the required interface function()
type MemoryPersistence ¶
MemoryPersistence is an implementation of a Persistence that stores the ControlPackets in memory using a map
func (*MemoryPersistence) All ¶
func (m *MemoryPersistence) All() []packets.ControlPacket
All is the library provided MemoryPersistence's implementation of the required interface function()
func (*MemoryPersistence) Close ¶
func (m *MemoryPersistence) Close()
Close is the library provided MemoryPersistence's implementation of the required interface function()
func (*MemoryPersistence) Delete ¶
func (m *MemoryPersistence) Delete(id uint16)
Delete is the library provided MemoryPersistence's implementation of the required interface function()
func (*MemoryPersistence) Get ¶
func (m *MemoryPersistence) Get(id uint16) packets.ControlPacket
Get is the library provided MemoryPersistence's implementation of the required interface function()
func (*MemoryPersistence) Open ¶
func (m *MemoryPersistence) Open()
Open is the library provided MemoryPersistence's implementation of the required interface function()
func (*MemoryPersistence) Put ¶
func (m *MemoryPersistence) Put(id uint16, cp packets.ControlPacket)
Put is the library provided MemoryPersistence's implementation of the required interface function()
func (*MemoryPersistence) Reset ¶
func (m *MemoryPersistence) Reset()
Reset is the library provided MemoryPersistence's implementation of the required interface function()
type MessageHandler ¶
type MessageHandler func(*Publish)
MessageHandler is a type for a function that is invoked by a Router when it has received a Publish.
type NOOPLogger ¶
type NOOPLogger struct{}
NOOPLogger implements the logger that does not perform any operation by default. This allows us to efficiently discard the unwanted messages.
func (NOOPLogger) Printf ¶
func (NOOPLogger) Printf(format string, v ...interface{})
Printf is the library provided NOOPLogger's implementation of the required interface function(){}
func (NOOPLogger) Println ¶
func (NOOPLogger) Println(v ...interface{})
Println is the library provided NOOPLogger's implementation of the required interface function()
type Persistence ¶
type Persistence interface { Open() Put(uint16, packets.ControlPacket) Get(uint16) packets.ControlPacket All() []packets.ControlPacket Delete(uint16) Close() Reset() }
Persistence is an interface of the functions for a struct that is used to persist ControlPackets. Open() is an initialiser to prepare the Persistence for use Put() takes a uint16 which is a messageid and a ControlPacket to persist against that messageid Get() takes a uint16 which is a messageid and returns the persisted ControlPacket from the Persistence for that messageid All() returns a slice of all ControlPackets persisted Delete() takes a uint16 which is a messageid and deletes the associated stored ControlPacket from the Persistence Close() closes the Persistence Reset() clears the Persistence and prepares it to be reused
type PingFailHandler ¶
type PingFailHandler func(error)
PingFailHandler is a type for the function that is invoked when we have sent a Pingreq to the server and not received a Pingresp within 1.5x our pingtimeout
type PingHandler ¶
type PingHandler struct {
// contains filtered or unexported fields
}
PingHandler is the library provided default Pinger
func DefaultPingerWithCustomFailHandler ¶
func DefaultPingerWithCustomFailHandler(pfh PingFailHandler) *PingHandler
DefaultPingerWithCustomFailHandler returns an instance of the default Pinger but with a custom PingFailHandler that is called when the client has not received a response to a PingRequest within the appropriate amount of time
func (*PingHandler) PingResp ¶
func (p *PingHandler) PingResp()
PingResp is the library provided Pinger's implementation of the required interface function()
func (*PingHandler) SetDebug ¶
func (p *PingHandler) SetDebug(l Logger)
SetDebug sets the logger l to be used for printing debug information for the pinger
func (*PingHandler) Start ¶
func (p *PingHandler) Start(c net.Conn, pt time.Duration)
Start is the library provided Pinger's implementation of the required interface function()
func (*PingHandler) Stop ¶
func (p *PingHandler) Stop()
Stop is the library provided Pinger's implementation of the required interface function()
type Pinger ¶
Pinger is an interface of the functions for a struct that is used to manage sending PingRequests and responding to PingResponses Start() takes a net.Conn which is a connection over which an MQTT session has already been established, and a time.Duration of the keepalive setting passed to the server when the MQTT session was established. Stop() is used to stop the Pinger PingResp() is the function that is called by the Client when a PingResponse is received SetDebug() is used to pass in a Logger to be used to log debug information, for example sharing a logger with the main client
type Publish ¶
type Publish struct { PacketID uint16 QoS byte Retain bool Topic string Properties *PublishProperties Payload []byte }
Publish is a representation of the MQTT Publish packet
func PublishFromPacketPublish ¶
PublishFromPacketPublish takes a packets library Publish and returns a paho library Publish
func (*Publish) InitProperties ¶
func (p *Publish) InitProperties(prop *packets.Properties)
InitProperties is a function that takes a lower level Properties struct and completes the properties of the Publish on which it is called
type PublishProperties ¶
type PublishProperties struct { CorrelationData []byte ContentType string ResponseTopic string PayloadFormat *byte MessageExpiry *uint32 SubscriptionIdentifier *int TopicAlias *uint16 User UserProperties }
PublishProperties is a struct of the properties that can be set for a Publish packet
type PublishResponse ¶
type PublishResponse struct { Properties *PublishResponseProperties ReasonCode byte }
PublishResponse is a generic representation of a response to a QoS1 or QoS2 Publish
func PublishResponseFromPuback ¶
func PublishResponseFromPuback(pa *packets.Puback) *PublishResponse
PublishResponseFromPuback takes a packets library Puback and returns a paho library PublishResponse
func PublishResponseFromPubcomp ¶
func PublishResponseFromPubcomp(pc *packets.Pubcomp) *PublishResponse
PublishResponseFromPubcomp takes a packets library Pubcomp and returns a paho library PublishResponse
func PublishResponseFromPubrec ¶
func PublishResponseFromPubrec(pr *packets.Pubrec) *PublishResponse
PublishResponseFromPubrec takes a packets library Pubrec and returns a paho library PublishResponse
type PublishResponseProperties ¶
type PublishResponseProperties struct { ReasonString string User UserProperties }
PublishResponseProperties is the properties associated with a response to a QoS1 or QoS2 Publish
type Router ¶
type Router interface { RegisterHandler(string, MessageHandler) UnregisterHandler(string) Route(*packets.Publish) SetDebugLogger(Logger) }
Router is an interface of the functions for a struct that is used to handle invoking MessageHandlers depending on the the topic the message was published on. RegisterHandler() takes a string of the topic, and a MessageHandler to be invoked when Publishes are received that match that topic UnregisterHandler() takes a string of the topic to remove MessageHandlers for Route() takes a Publish message and determines which MessageHandlers should be invoked
type SingleHandlerRouter ¶
SingleHandlerRouter is a library provided implementation of a Router that stores only a single MessageHandler and invokes this MessageHandler for all received Publishes
func NewSingleHandlerRouter ¶
func NewSingleHandlerRouter(h MessageHandler) *SingleHandlerRouter
NewSingleHandlerRouter instantiates and returns an instance of a SingleHandlerRouter
func (*SingleHandlerRouter) RegisterHandler ¶
func (s *SingleHandlerRouter) RegisterHandler(topic string, h MessageHandler)
RegisterHandler is the library provided SingleHandlerRouter's implementation of the required interface function()
func (*SingleHandlerRouter) Route ¶
func (s *SingleHandlerRouter) Route(pb *packets.Publish)
Route is the library provided SingleHandlerRouter's implementation of the required interface function()
func (*SingleHandlerRouter) SetDebugLogger ¶
func (s *SingleHandlerRouter) SetDebugLogger(l Logger)
SetDebugLogger sets the logger l to be used for printing debug information for the router
func (*SingleHandlerRouter) UnregisterHandler ¶
func (s *SingleHandlerRouter) UnregisterHandler(topic string)
UnregisterHandler is the library provided SingleHandlerRouter's implementation of the required interface function()
type StandardRouter ¶
StandardRouter is a library provided implementation of a Router that allows for unique and multiple MessageHandlers per topic
func NewStandardRouter ¶
func NewStandardRouter() *StandardRouter
NewStandardRouter instantiates and returns an instance of a StandardRouter
func (*StandardRouter) RegisterHandler ¶
func (r *StandardRouter) RegisterHandler(topic string, h MessageHandler)
RegisterHandler is the library provided StandardRouter's implementation of the required interface function()
func (*StandardRouter) Route ¶
func (r *StandardRouter) Route(pb *packets.Publish)
Route is the library provided StandardRouter's implementation of the required interface function()
func (*StandardRouter) SetDebugLogger ¶
func (r *StandardRouter) SetDebugLogger(l Logger)
SetDebugLogger sets the logger l to be used for printing debug information for the router
func (*StandardRouter) UnregisterHandler ¶
func (r *StandardRouter) UnregisterHandler(topic string)
UnregisterHandler is the library provided StandardRouter's implementation of the required interface function()
type Suback ¶
type Suback struct { Properties *SubackProperties Reasons []byte }
Suback is a representation of an MQTT suback packet
func SubackFromPacketSuback ¶
SubackFromPacketSuback takes a packets library Suback and returns a paho library Suback
type SubackProperties ¶
type SubackProperties struct { ReasonString string User UserProperties }
SubackProperties is a struct of the properties that can be set for a Suback packet
type Subscribe ¶
type Subscribe struct { Properties *SubscribeProperties Subscriptions map[string]SubscribeOptions }
Subscribe is a representation of a MQTT subscribe packet
func (*Subscribe) InitProperties ¶
func (s *Subscribe) InitProperties(prop *packets.Properties)
InitProperties is a function that takes a packet library Properties struct and completes the properties of the Subscribe on which it is called
func (*Subscribe) Packet ¶
Packet returns a packets library Subscribe from the paho Subscribe on which it is called
func (*Subscribe) PacketSubOptionsFromSubscribeOptions ¶
func (s *Subscribe) PacketSubOptionsFromSubscribeOptions() map[string]packets.SubOptions
PacketSubOptionsFromSubscribeOptions returns a map of string to packet library SubOptions for the paho Subscribe on which it is called
type SubscribeOptions ¶
SubscribeOptions is the struct representing the options for a subscription
type SubscribeProperties ¶
type SubscribeProperties struct { SubscriptionIdentifier *int User UserProperties }
SubscribeProperties is a struct of the properties that can be set for a Subscribe packet
type Unsuback ¶
type Unsuback struct { Reasons []byte Properties *UnsubackProperties }
Unsuback is a representation of an MQTT Unsuback packet
func UnsubackFromPacketUnsuback ¶
UnsubackFromPacketUnsuback takes a packets library Unsuback and returns a paho library Unsuback
type UnsubackProperties ¶
type UnsubackProperties struct { ReasonString string User UserProperties }
UnsubackProperties is a struct of the properties that can be set for a Unsuback packet
type Unsubscribe ¶
type Unsubscribe struct { Topics []string Properties *UnsubscribeProperties }
Unsubscribe is a representation of an MQTT unsubscribe packet
func (*Unsubscribe) Packet ¶
func (u *Unsubscribe) Packet() *packets.Unsubscribe
Packet returns a packets library Unsubscribe from the paho Unsubscribe on which it is called
type UnsubscribeProperties ¶
type UnsubscribeProperties struct {
User UserProperties
}
UnsubscribeProperties is a struct of the properties that can be set for a Unsubscribe packet
type UserProperties ¶
type UserProperties []UserProperty
UserProperties is a slice of UserProperty
func UserPropertiesFromPacketUser ¶
func UserPropertiesFromPacketUser(up []packets.User) UserProperties
UserPropertiesFromPacketUser converts a slice of packets.User to an instance of UserProperties for easier consumption within the client library
func (*UserProperties) Add ¶
func (u *UserProperties) Add(key, value string) *UserProperties
Add is a helper function for easily adding a new user property
func (UserProperties) Get ¶
func (u UserProperties) Get(key string) string
Get returns the first entry in the UserProperties that matches key, or an empty string if the key is not found. Note that it is permitted to have multiple entries with the same key, use GetAll if it is expected to have multiple matches
func (UserProperties) GetAll ¶
func (u UserProperties) GetAll(key string) []string
GetAll returns a slice of all entries in the UserProperties that match key, or a nil slice if none were found.
func (UserProperties) ToPacketProperties ¶
func (u UserProperties) ToPacketProperties() []packets.User
ToPacketProperties converts a UserProperties to a slice of packets.User which is used internally in the packets library for user properties
type UserProperty ¶
type UserProperty struct {
Key, Value string
}
UserProperty is a struct for the user provided values permitted in the properties section
type WillMessage ¶
WillMessage is a representation of the LWT message that can be sent with the Connect packet
type WillProperties ¶
type WillProperties struct { WillDelayInterval *uint32 PayloadFormat *byte MessageExpiry *uint32 ContentType string ResponseTopic string CorrelationData []byte User UserProperties }
WillProperties is a struct of the properties that can be set for a Will in a Connect packet