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" json:"name,optional"` Protocol string `yaml:"Protocol" json:"protocol,optional"` CaFilePath string `yaml:"CaFilePath" json:"caFilePath,optional"` //tls(ssl wss) 证书位置 Server string `yaml:"Server" json:"server,optional"` Port int `yaml:"Port" json:"port,optional"` ClientId string `yaml:"ClientId" json:"clientId,optional"` User string `yaml:"User" json:"user,optional"` Secret string `yaml:"Secret" json:"secret,optional"` KeepAlive int64 `yaml:"KeepAlive" json:"keepAlive,optional"` //s AutoReconnect bool `yaml:"AutoReconnect" json:"autoReconnect,optional"` ConnectRetry bool `yaml:"ConnectRetry" json:"connectRetry,optional"` ConnectTimeout int64 `yaml:"ConnectTimeout" 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.