client

package
v1.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 17, 2021 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

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

type Client struct {
	Clients map[string]mqtt.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

func (c *Client) Connect() mqtt.Token

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

func (c *Client) Disconnect(quiesce uint)

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

func (c *Client) IsConnected() bool

IsConnected returns a bool signifying whether the client is connected to all mqtt brokers or not.

func (*Client) IsConnectionOpen

func (c *Client) IsConnectionOpen() bool

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

func (c *Client) Publish(topic string, qos byte, retained bool, payload interface{}) mqtt.Token

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

func (c *Client) Subscribe(topic string, qos byte, callback mqtt.MessageHandler) mqtt.Token

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.

func (*Client) Unsubscribe

func (c *Client) Unsubscribe(topics ...string) mqtt.Token

Unsubscribe will end the subscription from each of the topics provided. Messages published to those topics from other clients will no longer be received.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL