Documentation ¶
Index ¶
- Constants
- 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 ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { Protocol string `yaml:"Protocol" json:"protocol"` CaFilePath string `yaml:"CaFilePath" json:"caFilePath"` //tls(ssl wss) 证书位置 Server string `yaml:"Server" json:"server"` Port int `yaml:"Port" json:"port"` ClientId string `yaml:"ClientId" json:"clientId"` User string `yaml:"User" json:"user"` Secret string `yaml:"Secret" json:"secret"` KeepAlive int64 `yaml:"KeepAlive" json:"keepAlive"` //s AutoReconnect bool `yaml:"AutoReconnect" json:"autoReconnect"` ConnectRetry bool `yaml:"ConnectRetry" json:"connectRetry"` ConnectTimeout int64 `yaml:"ConnectTimeout" json:"connectTimeout"` DefaultHandler *mqtt.MessageHandler OnConnect *mqtt.OnConnectHandler OnConnectionLost *mqtt.ConnectionLostHandler }
type GoMqttClient ¶
func New ¶
func New(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.