Versions in this module Expand all Collapse all v0 v0.0.2 Apr 16, 2024 v0.0.1 Apr 16, 2024 Changes in this version + const ConnectEvent + const DisconnectEvent + const NullEvent + var MqttList = CreateSafeMQTTList() + var MqttRespOption = &MqttRespOptionType + var SendDefaultQos byte = 0 + func CreateClient(optionHandler func(*ClientCallBackOption, *Config)) + type Client struct + Cfg *Config + Client *mqtt.Client + IsInit bool + MessageCallbackFunc MessageHandler + OnConnectCallBackFunc mqtt.OnConnectHandler + func (t *Client) Json() *MqttResp + func (t *Client) Run() + func (t *Client) SendMsg(msg any, topic string, qos ...byte) error + func (t *Client) SetMessageCallbackFunc(fn MessageHandler) *Client + func (t *Client) SetOnConnectCallBackFunc(fn mqtt.OnConnectHandler) *Client + type ClientCallBackOption struct + MessageCallbackFunc MessageHandler + OnConnectCallBackFunc mqtt.OnConnectHandler + type Config struct + CleanSession bool + ClientId string + Debug bool + MqttUrl string + Name string + Password string + Ping int + Qos byte + Subscribe string + Username string + type EventHandlerData struct + EventData any + MsgHandlerData *MessageHandlerData + func (t *EventHandlerData) GetJson() (json *gjson.Json) + func (t *EventHandlerData) SendMsg(msg any, topic string, qos ...byte) error + type MessageHandler func(handlerData *MessageHandlerData) + type MessageHandlerData struct + CMQTT *Client + Message mqtt.Message + OMQTT mqtt.Client + func (t *MessageHandlerData) GetEvent() (eventName string, data any, err error) + func (t *MessageHandlerData) GetMessageId() uint16 + func (t *MessageHandlerData) GetMsg() string + func (t *MessageHandlerData) GetTopic() string + type MqttResp struct + func CreateMqttResp(client *Client) *MqttResp + func (t *MqttResp) Err() *MqttResp + func (t *MqttResp) Resp(topic, command string, advanced ...func(data map[string]any) map[string]any) + func (t *MqttResp) SetCode(code int) *MqttResp + func (t *MqttResp) SetData(data any) *MqttResp + func (t *MqttResp) SetMsg(msg string) *MqttResp + type MqttRespOptionType struct + ErrorCode int + ErrorMsg string + SuccessCode int + SuccessMsg string + type SafeMQTTList struct + M map[string]*Client + func CreateSafeMQTTList() *SafeMQTTList + func (t *SafeMQTTList) Get(mqttName string) *Client + func (t *SafeMQTTList) Set(mqttName string, client *Client) + type SystemConnectEvent struct + ClientId string + Event string + func IsSystemConnectEvent(message, topic string) (*SystemConnectEvent, bool, error) + func (t *SystemConnectEvent) IsCurrentService(clientId string) bool