Documentation
¶
Index ¶
- Variables
- type Client
- func (c *Client) Connect(ctx context.Context) error
- func (c *Client) DisconnectImmediately()
- func (c *Client) Handle(topic string, handler MessageHandler) Route
- func (c *Client) Listen(topic string) (chan Message, Route)
- func (c *Client) Publish(ctx context.Context, topic string, payload []byte, qos QOS, ...) error
- func (c *Client) PublishJSON(ctx context.Context, topic string, payload interface{}, qos QOS, ...) error
- func (c *Client) PublishString(ctx context.Context, topic string, payload string, qos QOS, ...) error
- func (c *Client) Subscribe(ctx context.Context, topic string, qos QOS) error
- func (c *Client) Unsubscribe(ctx context.Context, topic string) error
- type ClientOptions
- type Message
- type MessageHandler
- type PublishOption
- type QOS
- type Route
Constants ¶
This section is empty.
Variables ¶
View Source
var (
ErrMinimumOneServer = errors.New("mqtt: at least one server needs to be specified")
)
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
Options ClientOptions // The options that were used to create this client
// contains filtered or unexported fields
}
Client for talking using mqtt
func NewClient ¶
func NewClient(options ClientOptions) (*Client, error)
NewClient creates a new client with the specified options
func (*Client) DisconnectImmediately ¶
func (c *Client) DisconnectImmediately()
Disconnect will immediately close the conenction with the mqtt servers
func (*Client) PublishJSON ¶
func (*Client) PublishString ¶
type ClientOptions ¶
type ClientOptions struct {
Servers []string // The list of broker hostnames to connect to
ClientID string // If left empty a uuid will automatically be generated
Username string // If not set then authentication will not be used
Password string // Will only be used if the username is set
AutoReconnect bool // If the client should automatically try to reconnect when the connection is lost
}
ClientOptions is the list of options used to create a client
type Message ¶
type Message struct {
// contains filtered or unexported fields
}
func (*Message) Acknowledge ¶
func (m *Message) Acknowledge()
func (*Message) IsDuplicate ¶
func (*Message) PayloadJSON ¶
func (*Message) PayloadString ¶
type MessageHandler ¶
type MessageHandler func(Message)
Click to show internal directories.
Click to hide internal directories.