Documentation ¶
Index ¶
- Constants
- Variables
- func CheckTopic(topic string, wildcard bool) bool
- func GetTLSCommonName(conn Connection) (string, bool)
- func MatchTopicQOS(t *Trie, topic string) (bool, uint32)
- type Client
- type ClientConfig
- type ClientOptions
- type Connack
- type ConnackCode
- type Connect
- type Connection
- type Counter
- type Dialer
- type Disconnect
- type Future
- type ID
- type Launcher
- type Message
- type Observer
- type ObserverWrapper
- type OnError
- type OnPuback
- type OnPublish
- type Packet
- type Pingreq
- type Pingresp
- type Puback
- type Publish
- type QOS
- type QOSTopic
- type Server
- type Suback
- type Subscribe
- type Subscription
- type Subscriptions
- type TopicChecker
- type Tracker
- type Trie
- type Type
- type Unsuback
- type Unsubscribe
Constants ¶
const ( Version311 byte = 4 Version31 byte = 3 )
The supported MQTT versions.
Variables ¶
var ( // client's erros ErrClientAlreadyConnecting = gomqtt.ErrClientAlreadyConnecting ErrClientNotConnected = gomqtt.ErrClientNotConnected ErrClientMissingID = gomqtt.ErrClientMissingID ErrClientConnectionDenied = gomqtt.ErrClientConnectionDenied ErrClientMissingPong = gomqtt.ErrClientMissingPong ErrClientExpectedConnack = gomqtt.ErrClientExpectedConnack ErrClientSubscriptionFailed = gomqtt.ErrFailedSubscription ErrClientAlreadyClosed = errors.New("client is closed") // future's errors ErrFutureTimeout = future.ErrTimeout ErrFutureCanceled = future.ErrCanceled )
all gomqtt client errors
Functions ¶
func GetTLSCommonName ¶
func GetTLSCommonName(conn Connection) (string, bool)
GetTLSCommonName check bidirectional authentication and return commonName
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client auto reconnection client
func (*Client) Publish ¶
func (c *Client) Publish(qos QOS, topic string, payload []byte, pid ID, retain bool, dup bool) error
Publish sends a publish packet
func (*Client) Subscribe ¶
func (c *Client) Subscribe(s []Subscription) error
Subscribe sends a subscribe packet
type ClientConfig ¶
type ClientConfig struct { Address string `yaml:"address" json:"address"` Username string `yaml:"username" json:"username"` Password string `yaml:"password" json:"password"` ClientID string `yaml:"clientid" json:"clientid"` CleanSession bool `yaml:"cleansession" json:"cleansession"` Timeout time.Duration `yaml:"timeout" json:"timeout" default:"30s"` KeepAlive time.Duration `yaml:"keepalive" json:"keepalive" default:"30s"` MaxReconnectInterval time.Duration `yaml:"maxReconnectInterval" json:"maxReconnectInterval" default:"3m"` MaxCacheMessages int `yaml:"maxCacheMessages" json:"maxCacheMessages" default:"10"` DisableAutoAck bool `yaml:"disableAutoAck" json:"disableAutoAck"` Subscriptions Subscriptions `yaml:"subscriptions" json:"subscriptions" default:"[]"` utils.Certificate `yaml:",inline" json:",inline"` }
ClientConfig client config
func (ClientConfig) ToClientOptions ¶
func (cc ClientConfig) ToClientOptions(obs Observer) (*ClientOptions, error)
ToClientOptions converts client config to client options
type ClientOptions ¶
type ClientOptions struct { Address string Username string Password string TLSConfig *tls.Config ClientID string CleanSession bool Timeout time.Duration KeepAlive time.Duration MaxReconnectInterval time.Duration MaxMessageSize utils.Size MaxCacheMessages int DisableAutoAck bool Observer Observer Subscriptions []Subscription }
ClientOptions client options
func NewClientOptions ¶
func NewClientOptions() ClientOptions
NewClientOptions creates client options with default values
type ConnackCode ¶
type ConnackCode = packet.ConnackCode
The ConnackCode represents the return code in a Connack packet.
const ( ConnectionAccepted ConnackCode = iota InvalidProtocolVersion IdentifierRejected BadUsernameOrPassword NotAuthorized )
All available ConnackCodes.
type Connection ¶
Connection the connection between a client and a server
type Observer ¶
type Observer interface { OnPublish(*packet.Publish) error OnPuback(*packet.Puback) error OnError(error) }
Observer message observer interface
type ObserverWrapper ¶
type ObserverWrapper struct {
// contains filtered or unexported fields
}
ObserverWrapper MQTT message handler wrapper
func NewObserverWrapper ¶
func NewObserverWrapper(onPublish OnPublish, onPuback OnPuback, onError OnError) *ObserverWrapper
NewObserverWrapper creates a new handler wrapper
func (*ObserverWrapper) OnError ¶
func (h *ObserverWrapper) OnError(err error)
OnError handles error
type QOSTopic ¶
type QOSTopic struct { QOS uint32 `yaml:"qos" json:"qos" validate:"min=0, max=1"` Topic string `yaml:"topic" json:"topic" validate:"nonzero"` }
QOSTopic topic and qos
type Subscription ¶
type Subscription = packet.Subscription
Subscription the topic and qos of subscription
type Subscriptions ¶
type Subscriptions []QOSTopic
Subscriptions subscriptions
func (Subscriptions) ToMQTTSubscriptions ¶
func (ss Subscriptions) ToMQTTSubscriptions() []Subscription
ToMQTTSubscriptions converts to mqtt subscriptions
type TopicChecker ¶
type TopicChecker struct {
// contains filtered or unexported fields
}
TopicChecker checks topic
func NewTopicChecker ¶
func NewTopicChecker(sysTopics []string) *TopicChecker
NewTopicChecker create topicChecker
func (*TopicChecker) CheckTopic ¶
func (tc *TopicChecker) CheckTopic(topic string, wildcard bool) bool
CheckTopic checks the topic
type Unsubscribe ¶
type Unsubscribe = packet.Unsubscribe
Unsubscribe the unsubscribe packet
func NewUnsubscribe ¶
func NewUnsubscribe() *Unsubscribe
NewUnsubscribe creates a new Unsubscribe packet