Documentation ¶
Index ¶
- Constants
- func Init(configs ...Config) (err error)
- type Config
- type GoMqttClient
- func (g *GoMqttClient) Connect() error
- func (g *GoMqttClient) Disconnect(quiesce uint)
- func (g *GoMqttClient) Publish(topic string, qos byte, retained bool, payload interface{}) error
- func (g *GoMqttClient) Subscribe(topic string, qos byte, callback mqtt.MessageHandler) error
- func (g *GoMqttClient) Unsubscribe(topics ...string) error
Constants ¶
View Source
const ( PROTOCOL_TCP = "tcp" PROTOCOL_SSL = "ssl" PROTOCOL_WS = "ws" PROTOCOL_WSS = "wss" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct { Name string `yaml:"Name,optional" json:"name,optional"` Protocol string `yaml:"Protocol,optional" json:"protocol,optional"` CaFilePath string `yaml:"CaFilePath,optional" json:"caFilePath,optional"` //tls(ssl wss) 证书位置 Server string `yaml:"Server,optional" json:"server,optional"` Port int `yaml:"Port,optional" json:"port,optional"` ClientId string `yaml:"ClientId,optional" json:"clientId,optional"` User string `yaml:"User,optional" json:"user,optional"` Secret string `yaml:"Secret,optional" json:"secret,optional"` KeepAlive int64 `yaml:"KeepAlive,optional" json:"keepAlive,optional"` //s AutoReconnect bool `yaml:"AutoReconnect,optional" json:"autoReconnect,optional"` ConnectRetry bool `yaml:"ConnectRetry,optional" json:"connectRetry,optional"` ConnectTimeout int64 `yaml:"ConnectTimeout,optional" json:"connectTimeout,optional"` DefaultHandler *mqtt.MessageHandler OnConnect *mqtt.OnConnectHandler OnConnectionLost *mqtt.ConnectionLostHandler }
type GoMqttClient ¶
func Client ¶ added in v1.2.42
func Client() *GoMqttClient
func GetClient ¶ added in v1.2.42
func GetClient(names ...string) *GoMqttClient
func NewClient ¶ added in v1.2.42
func NewClient(config Config) (*GoMqttClient, error)
func NewConfig ¶
func NewConfig(opts *mqtt.ClientOptions) (*GoMqttClient, error)
func (*GoMqttClient) Connect ¶
func (g *GoMqttClient) Connect() error
func (*GoMqttClient) Disconnect ¶
func (g *GoMqttClient) Disconnect(quiesce uint)
func (*GoMqttClient) Publish ¶
func (g *GoMqttClient) Publish(topic string, qos byte, retained bool, payload interface{}) error
func (*GoMqttClient) Subscribe ¶
func (g *GoMqttClient) Subscribe(topic string, qos byte, callback mqtt.MessageHandler) error
func (*GoMqttClient) Unsubscribe ¶
func (g *GoMqttClient) Unsubscribe(topics ...string) error
Click to show internal directories.
Click to hide internal directories.