Documentation ¶
Index ¶
- Constants
- type Client
- func (client *Client) Connect() error
- func (client *Client) GetClientID() string
- func (client *Client) Publish(topic string, qos byte, retained bool, data []byte) error
- func (client *Client) Subscribe(observer func(c *Client, msg *Message), qos byte, topics ...string) error
- func (client *Client) Unsubscribe(topics ...string)
- type Message
Constants ¶
View Source
const ( //Host = "192.168.31.32:1883" //UserName = "root" //Password = "root" Host = "47.116.75.143:1883" UserName = "client" Password = "hi2020go" )
mqtt服务器配置
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (*Client) GetClientID ¶
func (*Client) Subscribe ¶
func (client *Client) Subscribe(observer func(c *Client, msg *Message), qos byte, topics ...string) error
消费消息
func (*Client) Unsubscribe ¶
type Message ¶
type Message struct { // client_id ClientID string `json:"client_id"` // 接口名,订阅号通过识别接口名处理相应业务 Action string `json:"action"` // 数据类型 Type string `json:"type"` // 发布时间 Time int64 `json:"time"` // 业务数据的header,可以携带一些系统参数 Header interface{} `json:"header"` // 业务数据的body,业务参数 Body interface{} `json:"body"` }
Click to show internal directories.
Click to hide internal directories.