Documentation
¶
Overview ¶
Package paho provides an iot.MQTTClient implementation that uses the Eclipse Paho MQTT client. To use the client, you must import this package.
Index ¶
- func NewClient(thing iot.Thing, options *iot.ThingOptions) iot.MQTTClient
- type MQTTClient
- func (c *MQTTClient) Connect(ctx context.Context, servers ...string) error
- func (c *MQTTClient) Disconnect(ctx context.Context) error
- func (c *MQTTClient) IsConnected() bool
- func (c *MQTTClient) Publish(ctx context.Context, topic string, qos uint8, payload interface{}) error
- func (c *MQTTClient) SetClientID(clientID string)
- func (c *MQTTClient) SetCredentialsProvider(credentialsProvider iot.MQTTCredentialsProvider)
- func (c *MQTTClient) SetDebugLogger(logger iot.Logger)
- func (c *MQTTClient) SetErrorLogger(logger iot.Logger)
- func (c *MQTTClient) SetInfoLogger(logger iot.Logger)
- func (c *MQTTClient) SetOnConnectHandler(handler iot.MQTTOnConnectHandler)
- func (c *MQTTClient) Subscribe(ctx context.Context, topic string, qos uint8, callback iot.ConfigHandler) error
- func (c *MQTTClient) Unsubscribe(ctx context.Context, topic string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewClient ¶
func NewClient(thing iot.Thing, options *iot.ThingOptions) iot.MQTTClient
NewClient creates an MQTTClient instance using Eclipse Paho.
Types ¶
type MQTTClient ¶
type MQTTClient struct {
// contains filtered or unexported fields
}
MQTTClient is an implementation of MQTTClient that uses Eclipse Paho. To use the client, you must include this package.
func (*MQTTClient) Connect ¶
func (c *MQTTClient) Connect(ctx context.Context, servers ...string) error
Connect should connect to the given MQTT server
func (*MQTTClient) Disconnect ¶
func (c *MQTTClient) Disconnect(ctx context.Context) error
Disconnect will disconnect from the given MQTT server and clean up all client resources
func (*MQTTClient) IsConnected ¶
func (c *MQTTClient) IsConnected() bool
IsConnected should return true when the client is connected to the server
func (*MQTTClient) Publish ¶
func (c *MQTTClient) Publish(ctx context.Context, topic string, qos uint8, payload interface{}) error
Publish will publish the given payload to the given topic with the given quality of service level
func (*MQTTClient) SetClientID ¶
func (c *MQTTClient) SetClientID(clientID string)
SetClientID sets the MQTT client id
func (*MQTTClient) SetCredentialsProvider ¶
func (c *MQTTClient) SetCredentialsProvider(credentialsProvider iot.MQTTCredentialsProvider)
SetCredentialsProvider sets the CredentialsProvider used by the MQTT client
func (*MQTTClient) SetDebugLogger ¶
func (c *MQTTClient) SetDebugLogger(logger iot.Logger)
SetDebugLogger sets the logger to use for logging debug messages
func (*MQTTClient) SetErrorLogger ¶
func (c *MQTTClient) SetErrorLogger(logger iot.Logger)
SetErrorLogger sets the logger to use for logging error or critical messages
func (*MQTTClient) SetInfoLogger ¶
func (c *MQTTClient) SetInfoLogger(logger iot.Logger)
SetInfoLogger sets the logger to use for logging information or warning messages
func (*MQTTClient) SetOnConnectHandler ¶
func (c *MQTTClient) SetOnConnectHandler(handler iot.MQTTOnConnectHandler)
SetOnConnectHandler sets the method that is called after the client connects to the server
func (*MQTTClient) Subscribe ¶
func (c *MQTTClient) Subscribe(ctx context.Context, topic string, qos uint8, callback iot.ConfigHandler) error
Subscribe will subscribe to the given topic with the given quality of service level and message handler