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 Client
- func (c *Client) Ack(pb *Publish) error
- func (c *Client) AddOnPublishReceived(f func(PublishReceived) (bool, error)) func()
- func (c *Client) Authenticate(ctx context.Context, a *Auth) (*AuthResponse, error)
- func (c *Client) ClientID() string
- func (c *Client) Connect(ctx context.Context, cp *Connect) (*Connack, error)
- func (c *Client) Disconnect(d *Disconnect) error
- func (c *Client) Done() <-chan struct{}
- func (c *Client) Publish(ctx context.Context, p *Publish) (*PublishResponse, error)
- func (c *Client) PublishWithOptions(ctx context.Context, p *Publish, o PublishOptions) (*PublishResponse, error)
- func (c *Client) SetDebugLogger(l log.Logger)
- func (c *Client) SetErrorLogger(l log.Logger)
- func (c *Client) Subscribe(ctx context.Context, s *Subscribe) (*Suback, error)
- func (c *Client) TerminateConnectionForTest()
- func (c *Client) Unsubscribe(ctx context.Context, u *Unsubscribe) (*Unsuback, error)
- type ClientConfig
- type CommsProperties
- type Connack
- type ConnackProperties
- type Connect
- type ConnectProperties
- type DefaultPinger
- type Disconnect
- type DisconnectProperties
- type MessageHandler
- type Pinger
- type Publish
- type PublishMethod
- type PublishOptions
- type PublishProperties
- type PublishReceived
- type PublishResponse
- type PublishResponseProperties
- type Router
- 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") ErrNetworkErrorAfterStored = errors.New("error after packet added to state") // Could not send packet but its stored (and response will be sent on chan at some point in the future) ErrConnectionLost = errors.New("connection lost after request transmitted") // We don't know whether the server received the request or not ErrInvalidArguments = errors.New("invalid argument") // If included (errors.Join) in an error, there is a problem with the arguments passed. Retrying on the same connection with the same arguments will not succeed. )
var ErrPacketNotFound = errors.New("packet not found")
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 ¶
type Auther interface {
Authenticate(*Auth) *Auth // Authenticate will be called when an AUTH packet is received.
Authenticated() // Authenticated will be called when CONNACK is received
}
Auther is the interface for something that implements the extended authentication flows in MQTT v5
type Client ¶
type Client struct {
// 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) Ack ¶
Ack transmits an acknowledgement of the `Publish` packet. WARNING: Calling Ack after the connection is closed may have unpredictable results (particularly if the sessionState is being accessed by a new connection). See issue #160.
func (*Client) AddOnPublishReceived ¶
func (c *Client) AddOnPublishReceived(f func(PublishReceived) (bool, error)) func()
AddOnPublishReceived adds a function that will be called when a PUBLISH is received The new function will be called after any functions already in the list Returns a function that can be called to remove the callback
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) ClientID ¶
ClientID retrieves the client ID from the config (sometimes used in handlers that require the ID)
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) Done ¶
func (c *Client) Done() <-chan struct{}
Done returns a channel that will be closed when Client has shutdown. Only valid after Connect has returned a nil error.
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. A PublishResponse is returned, which is relevant for QOS1+. For QOS0, a default success response is returned. Note that a message may still be delivered even if Publish times out (once the message is part of the session state, it may even be delivered following an application restart). Warning: Publish may outlive the connection when QOS1+ (managed in `session_state`)
func (*Client) PublishWithOptions ¶
func (c *Client) PublishWithOptions(ctx context.Context, p *Publish, o PublishOptions) (*PublishResponse, error)
PublishWithOptions is used to send a publication to the MQTT server (with options to customise its behaviour) It is passed a pre-prepared Publish packet and, by default, blocks waiting for the appropriate response, or for the timeout to fire. A PublishResponse is returned, which is relevant for QOS1+. For QOS0, a default success response is returned. Note that a message may still be delivered even if Publish times out (once the message is part of the session state, it may even be delivered following an application restart). Warning: Publish may outlive the connection when QOS1+ (managed in `session_state`)
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) TerminateConnectionForTest ¶
func (c *Client) TerminateConnectionForTest()
TerminateConnectionForTest closes the active connection (if any). This function is intended for testing only, it simulates connection loss which supports testing QOS1 and 2 message delivery.
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
Session session.SessionManager
AuthHandler Auther
PingHandler Pinger
// Router - new inbound messages will be passed to the `Route(*packets.Publish)` function.
//
// Depreciated: If a router is provided, it will now be added to the end of the OnPublishReceived
// slice (which provides a more flexible approach to handling incoming messages).
Router Router
// OnPublishReceived provides a slice of callbacks; additional handlers may be added after the client has been
// created via the AddOnPublishReceived function (Client holds a copy of the slice; OnPublishReceived will not change).
// When a `PUBLISH` is received, the callbacks will be called in order. If a callback processes the message,
// then it should return true. This boolean, and any errors, will be passed to subsequent handlers.
OnPublishReceived []func(PublishReceived) (bool, error)
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. Note that this may be called multiple times and may be
// called following a successful `Disconnect`. See autopaho.errorHandler for an example.
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
// contains filtered or unexported fields
}
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
func (*ConnackProperties) String ¶
func (p *ConnackProperties) String() string
String implement fmt.Stringer (mainly to simplify debugging)
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
MaximumPacketSize *uint32
User UserProperties
RequestProblemInfo bool
RequestResponseInfo bool
}
ConnectProperties is a struct of the properties that can be set for a Connect packet
type DefaultPinger ¶
type DefaultPinger struct {
// contains filtered or unexported fields
}
DefaultPinger is the default implementation of Pinger.
func NewDefaultPinger ¶
func NewDefaultPinger() *DefaultPinger
NewDefaultPinger creates a DefaultPinger
func (*DefaultPinger) PacketSent ¶
func (p *DefaultPinger) PacketSent()
func (*DefaultPinger) PingResp ¶
func (p *DefaultPinger) PingResp()
func (*DefaultPinger) Run ¶
Run starts the pinger; blocks until done (either context cancelled or error encountered)
func (*DefaultPinger) SetDebug ¶
func (p *DefaultPinger) SetDebug(debug log.Logger)
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 MessageHandler ¶
type MessageHandler func(*Publish)
MessageHandler is a type for a function that is invoked by a Router when it has received a Publish. MessageHandlers should complete quickly (start a go routine for long-running processes) and should not call functions within the paho instance that triggered them (due to potential deadlocks).
type Pinger ¶
type Pinger interface {
// Run starts the pinger. It blocks until the pinger is stopped.
// If the pinger stops due to an error, it returns the error.
// If the keepAlive is 0, it returns nil immediately.
// Run() may be called multiple times, but only after prior instances have terminated.
Run(ctx context.Context, conn net.Conn, keepAlive uint16) error
// PacketSent is called when a packet is sent to the server.
PacketSent()
// PingResp is called when a PINGRESP is received from the server.
PingResp()
// SetDebug sets the logger for debugging.
// It is not thread-safe and must be called before Run() to avoid race conditions.
SetDebug(log.Logger)
}
type Publish ¶
type Publish struct {
PacketID uint16
QoS byte
Retain bool
Topic string
Properties *PublishProperties
Payload []byte
// contains filtered or unexported fields
}
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) Duplicate ¶
Duplicate returns true if the duplicate flag is set (the server sets this if the message has been sent previously; this does not necessarily mean the client has previously processed the message).
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 PublishMethod ¶
type PublishMethod int
const ( PublishMethod_Blocking PublishMethod = iota // by default PublishWithOptions will block until the publish transaction is complete PublishMethod_AsyncSend // PublishWithOptions will add the message to the session and then return (no method to check status is provided) )
type PublishOptions ¶
type PublishOptions struct {
// Method enables a degree of control over how PublishWithOptions operates
Method PublishMethod
}
PublishOptions enables the behaviour of Publish to be modified
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 PublishReceived ¶
type PublishReceived struct {
Packet *Publish
Client *Client // The Client that received the message (note that the connection may have been lost post-receipt)
AlreadyHandled bool // Set to true if a previous callback has returned true (indicating some action has already been taken re the message)
Errs []error // Errors returned by previous handlers (if any).
}
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(log.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 StandardRouter ¶
StandardRouter is a library provided implementation of a Router that allows for unique and multiple MessageHandlers per topic
func NewSingleHandlerRouter
deprecated
func NewSingleHandlerRouter(h MessageHandler) *StandardRouter
NewSingleHandlerRouter instantiates a router that will call the passed in message handler for all inbound messages (assuming `RegisterHandler` is never called).
Deprecated: SingleHandlerRouter has been removed because it did not meet the requirements set out in the `Router` interface documentation. This function is only included to maintain compatibility, but there are limits (this version does not ignore calls to `RegisterHandler`).
func NewStandardRouter ¶
func NewStandardRouter() *StandardRouter
NewStandardRouter instantiates and returns an instance of a StandardRouter
func NewStandardRouterWithDefault ¶
func NewStandardRouterWithDefault(h MessageHandler) *StandardRouter
NewStandardRouterWithDefault instantiates and returns an instance of a StandardRouter with the default handler set to the value passed in (for convenience when creating handler inline).
func (*StandardRouter) DefaultHandler ¶
func (r *StandardRouter) DefaultHandler(h MessageHandler)
DefaultHandler sets handler to be called for messages that don't trigger another handler Pass nil to unset.
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 log.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 []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() []packets.SubOptions
PacketSubOptionsFromSubscribeOptions returns a slice of packet library SubOptions for the paho Subscribe on which it is called
type SubscribeOptions ¶
type SubscribeOptions struct {
Topic string
QoS byte
RetainHandling byte
NoLocal bool
RetainAsPublished bool
}
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