Documentation ¶
Index ¶
- func NewClient(opts *mqtt.ClientOptions) mqtt.Client
- func NewClientWithOptions(opts map[string]*mqtt.ClientOptions) mqtt.Client
- type Client
- func (c *Client) AddRoute(topic string, callback mqtt.MessageHandler)
- func (c *Client) Connect() mqtt.Token
- func (c *Client) Disconnect(quiesce uint)
- func (c *Client) IsConnected() bool
- func (c *Client) IsConnectionOpen() bool
- func (*Client) OptionsReader() mqtt.ClientOptionsReader
- func (c *Client) Publish(topic string, qos byte, retained bool, payload interface{}) mqtt.Token
- func (c *Client) Subscribe(topic string, qos byte, callback mqtt.MessageHandler) mqtt.Token
- func (c *Client) SubscribeMultiple(filters map[string]byte, callback mqtt.MessageHandler) mqtt.Token
- func (c *Client) Unsubscribe(topics ...string) mqtt.Token
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewClient ¶
func NewClient(opts *mqtt.ClientOptions) mqtt.Client
NewClient creates a pakhshi client based on given paho options. it uses the servers array for finding out about the clusters and also use their host name to name them.
func NewClientWithOptions ¶
func NewClientWithOptions(opts map[string]*mqtt.ClientOptions) mqtt.Client
NewClientWithOptions creates a pakhshi client based on given paho options and broker names.
Types ¶
type Client ¶
Client handles an array for clients to the available cluster by using this client you can control all avaialbe client at the same time. you also can use each client separately by their cluster name.
func (*Client) AddRoute ¶
func (c *Client) AddRoute(topic string, callback mqtt.MessageHandler)
AddRoute allows you to add a handler for messages on a specific topic without making a subscription. For example having a different handler for parts of a wildcard subscription or for receiving retained messages upon connection (before Sub scribe can be processed).
If options.OrderMatters is true (the default) then callback must not block or call functions within this package that may block (e.g. Publish) other than in a new go routine. callback must be safe for concurrent use by multiple goroutines.
func (*Client) Connect ¶
Connect will create a connection to the message broker, by default it will attempt to connect at v3.1.1 and auto retry at v3.1 if that fails.
func (*Client) Disconnect ¶
Disconnect will end the connection with the server, but not before waiting the specified number of milliseconds to wait for existing work to be completed. Please note that this time will be given to each broker.
func (*Client) IsConnected ¶
IsConnected returns a bool signifying whether the client is connected to all mqtt brokers or not.
func (*Client) IsConnectionOpen ¶
IsConnectionOpen return a bool signifying whether the client has an active connection to all mqtt brokers, i.e not in disconnected or reconnect mode.
func (*Client) OptionsReader ¶
func (*Client) OptionsReader() mqtt.ClientOptionsReader
OptionsReader returns a ClientOptionsReader which is a copy of the clientoptions in use by the client.
func (*Client) Publish ¶
Publish will publish a message with the specified QoS and content to the specified topic. Returns a token to track delivery of the message to the broker.
func (*Client) Subscribe ¶
Subscribe starts a new subscription. Provide a MessageHandler to be executed when a message is published on the topic provided, or nil for the default handler.
If options.OrderMatters is true (the default) then callback must not block or call functions within this package that may block (e.g. Publish) other than in a new go routine. callback must be safe for concurrent use by multiple goroutines.
func (*Client) SubscribeMultiple ¶
func (c *Client) SubscribeMultiple(filters map[string]byte, callback mqtt.MessageHandler) mqtt.Token
SubscribeMultiple starts a new subscription for multiple topics. Provide a MessageHandler to be executed when a message is published on one of the topics provided, or nil for the default handler.
If options.OrderMatters is true (the default) then callback must not block or call functions within this package that may block (e.g. Publish) other than in a new go routine. callback must be safe for concurrent use by multiple goroutines.