Versions in this module Expand all Collapse all v1 v1.4.2 Sep 10, 2022 Changes in this version + const CLI + const DEC + const ERR + const MES + const MID + const NET + const PNG + const ROU + const STA + const STR + const TST + var ErrInvalidQos = errors.New("invalid QoS") + var ErrInvalidTopicEmptyString = errors.New("invalid Topic; empty string") + var ErrInvalidTopicMultilevel = errors.New("invalid Topic; multi-level wildcard must be last level") + var ErrNotConnected = errors.New("not Connected") + func ConnectMQTT(conn net.Conn, cm *packets.ConnectPacket, protocolVersion uint) (byte, bool) + func DefaultConnectionLostHandler(client Client, reason error) + func NewWebsocket(host string, tlsc *tls.Config, timeout time.Duration, ...) (net.Conn, error) + type Client interface + AddRoute func(topic string, callback MessageHandler) + Connect func() Token + Disconnect func(quiesce uint) + IsConnected func() bool + IsConnectionOpen func() bool + OptionsReader func() ClientOptionsReader + Publish func(topic string, qos byte, retained bool, payload interface{}) Token + Subscribe func(topic string, qos byte, callback MessageHandler) Token + SubscribeMultiple func(filters map[string]byte, callback MessageHandler) Token + Unsubscribe func(topics ...string) Token + func NewClient(o *ClientOptions) Client + type ClientOptions struct + AutoReconnect bool + CleanSession bool + ClientID string + ConnectRetry bool + ConnectRetryInterval time.Duration + ConnectTimeout time.Duration + CredentialsProvider CredentialsProvider + CustomOpenConnectionFn OpenConnectionFunc + DefaultPublishHandler MessageHandler + Dialer *net.Dialer + HTTPHeaders http.Header + KeepAlive int64 + MaxReconnectInterval time.Duration + MaxResumePubInFlight int + MessageChannelDepth uint + OnConnect OnConnectHandler + OnConnectAttempt ConnectionAttemptHandler + OnConnectionLost ConnectionLostHandler + OnReconnecting ReconnectHandler + Order bool + Password string + PingTimeout time.Duration + ProtocolVersion uint + ResumeSubs bool + Servers []*url.URL + Store Store + TLSConfig *tls.Config + Username string + WebsocketOptions *WebsocketOptions + WillEnabled bool + WillPayload []byte + WillQos byte + WillRetained bool + WillTopic string + WriteTimeout time.Duration + func NewClientOptions() *ClientOptions + func (o *ClientOptions) AddBroker(server string) *ClientOptions + func (o *ClientOptions) SetAutoReconnect(a bool) *ClientOptions + func (o *ClientOptions) SetBinaryWill(topic string, payload []byte, qos byte, retained bool) *ClientOptions + func (o *ClientOptions) SetCleanSession(clean bool) *ClientOptions + func (o *ClientOptions) SetClientID(id string) *ClientOptions + func (o *ClientOptions) SetConnectRetry(a bool) *ClientOptions + func (o *ClientOptions) SetConnectRetryInterval(t time.Duration) *ClientOptions + func (o *ClientOptions) SetConnectTimeout(t time.Duration) *ClientOptions + func (o *ClientOptions) SetConnectionAttemptHandler(onConnectAttempt ConnectionAttemptHandler) *ClientOptions + func (o *ClientOptions) SetConnectionLostHandler(onLost ConnectionLostHandler) *ClientOptions + func (o *ClientOptions) SetCredentialsProvider(p CredentialsProvider) *ClientOptions + func (o *ClientOptions) SetCustomOpenConnectionFn(customOpenConnectionFn OpenConnectionFunc) *ClientOptions + func (o *ClientOptions) SetDefaultPublishHandler(defaultHandler MessageHandler) *ClientOptions + func (o *ClientOptions) SetDialer(dialer *net.Dialer) *ClientOptions + func (o *ClientOptions) SetHTTPHeaders(h http.Header) *ClientOptions + func (o *ClientOptions) SetKeepAlive(k time.Duration) *ClientOptions + func (o *ClientOptions) SetMaxReconnectInterval(t time.Duration) *ClientOptions + func (o *ClientOptions) SetMaxResumePubInFlight(MaxResumePubInFlight int) *ClientOptions + func (o *ClientOptions) SetMessageChannelDepth(s uint) *ClientOptions + func (o *ClientOptions) SetOnConnectHandler(onConn OnConnectHandler) *ClientOptions + func (o *ClientOptions) SetOrderMatters(order bool) *ClientOptions + func (o *ClientOptions) SetPassword(p string) *ClientOptions + func (o *ClientOptions) SetPingTimeout(k time.Duration) *ClientOptions + func (o *ClientOptions) SetProtocolVersion(pv uint) *ClientOptions + func (o *ClientOptions) SetReconnectingHandler(cb ReconnectHandler) *ClientOptions + func (o *ClientOptions) SetResumeSubs(resume bool) *ClientOptions + func (o *ClientOptions) SetStore(s Store) *ClientOptions + func (o *ClientOptions) SetTLSConfig(t *tls.Config) *ClientOptions + func (o *ClientOptions) SetUsername(u string) *ClientOptions + func (o *ClientOptions) SetWebsocketOptions(w *WebsocketOptions) *ClientOptions + func (o *ClientOptions) SetWill(topic string, payload string, qos byte, retained bool) *ClientOptions + func (o *ClientOptions) SetWriteTimeout(t time.Duration) *ClientOptions + func (o *ClientOptions) UnsetWill() *ClientOptions + type ClientOptionsReader struct + func (r *ClientOptionsReader) AutoReconnect() bool + func (r *ClientOptionsReader) CleanSession() bool + func (r *ClientOptionsReader) ClientID() string + func (r *ClientOptionsReader) ConnectRetry() bool + func (r *ClientOptionsReader) ConnectRetryInterval() time.Duration + func (r *ClientOptionsReader) ConnectTimeout() time.Duration + func (r *ClientOptionsReader) HTTPHeaders() http.Header + func (r *ClientOptionsReader) KeepAlive() time.Duration + func (r *ClientOptionsReader) MaxReconnectInterval() time.Duration + func (r *ClientOptionsReader) MessageChannelDepth() uint + func (r *ClientOptionsReader) Order() bool + func (r *ClientOptionsReader) Password() string + func (r *ClientOptionsReader) PingTimeout() time.Duration + func (r *ClientOptionsReader) ProtocolVersion() uint + func (r *ClientOptionsReader) ResumeSubs() bool + func (r *ClientOptionsReader) Servers() []*url.URL + func (r *ClientOptionsReader) TLSConfig() *tls.Config + func (r *ClientOptionsReader) Username() string + func (r *ClientOptionsReader) WebsocketOptions() *WebsocketOptions + func (r *ClientOptionsReader) WillEnabled() bool + func (r *ClientOptionsReader) WillPayload() []byte + func (r *ClientOptionsReader) WillQos() byte + func (r *ClientOptionsReader) WillRetained() bool + func (r *ClientOptionsReader) WillTopic() string + func (r *ClientOptionsReader) WriteTimeout() time.Duration + type ConnectToken struct + func (b *ConnectToken) Done() <-chan struct{} + func (b *ConnectToken) Error() error + func (b *ConnectToken) SetCallback(f func(Token)) + func (b *ConnectToken) Wait() bool + func (b *ConnectToken) WaitTimeout(d time.Duration) bool + func (c *ConnectToken) ReturnCode() byte + func (c *ConnectToken) SessionPresent() bool + type ConnectionAttemptHandler func(broker *url.URL, tlsCfg *tls.Config) *tls.Config + type ConnectionLostHandler func(Client, error) + type CredentialsProvider func() (username string, password string) + type DisconnectToken struct + func (b *DisconnectToken) Done() <-chan struct{} + func (b *DisconnectToken) Error() error + func (b *DisconnectToken) SetCallback(f func(Token)) + func (b *DisconnectToken) Wait() bool + func (b *DisconnectToken) WaitTimeout(d time.Duration) bool + type DummyToken struct + func (d *DummyToken) Done() <-chan struct{} + func (d *DummyToken) Error() error + func (d *DummyToken) SetCallback(f func(Token)) + func (d *DummyToken) Wait() bool + func (d *DummyToken) WaitTimeout(t time.Duration) bool + type FileStore struct + func NewFileStore(directory string) *FileStore + func (store *FileStore) All() []string + func (store *FileStore) Close() + func (store *FileStore) Del(key string) + func (store *FileStore) Get(key string) packets.ControlPacket + func (store *FileStore) Open() + func (store *FileStore) Put(key string, m packets.ControlPacket) + func (store *FileStore) Reset() + type Logger interface + Printf func(format string, v ...interface{}) + Println func(v ...interface{}) + var CRITICAL Logger = NOOPLogger{} + var DEBUG Logger = NOOPLogger{} + var ERROR Logger = NOOPLogger{} + var WARN Logger = NOOPLogger{} + type MId uint16 + type MemoryStore struct + func NewMemoryStore() *MemoryStore + func (store *MemoryStore) All() []string + func (store *MemoryStore) Close() + func (store *MemoryStore) Del(key string) + func (store *MemoryStore) Get(key string) packets.ControlPacket + func (store *MemoryStore) Open() + func (store *MemoryStore) Put(key string, message packets.ControlPacket) + func (store *MemoryStore) Reset() + type Message interface + Ack func() + Duplicate func() bool + MessageID func() uint16 + Payload func() []byte + Qos func() byte + Retained func() bool + Topic func() string + type MessageHandler func(Client, Message) + type NOOPLogger struct + func (NOOPLogger) Printf(format string, v ...interface{}) + func (NOOPLogger) Println(v ...interface{}) + type OnConnectHandler func(Client) + type OpenConnectionFunc func(uri *url.URL, options ClientOptions) (net.Conn, error) + type OrderedMemoryStore struct + func NewOrderedMemoryStore() *OrderedMemoryStore + func (store *OrderedMemoryStore) All() []string + func (store *OrderedMemoryStore) Close() + func (store *OrderedMemoryStore) Del(key string) + func (store *OrderedMemoryStore) Get(key string) packets.ControlPacket + func (store *OrderedMemoryStore) Open() + func (store *OrderedMemoryStore) Put(key string, message packets.ControlPacket) + func (store *OrderedMemoryStore) Reset() + type PacketAndToken struct + type PlaceHolderToken struct + func (p *PlaceHolderToken) Done() <-chan struct{} + func (p *PlaceHolderToken) Error() error + func (p *PlaceHolderToken) SetCallback(func(Token)) + func (p *PlaceHolderToken) Wait() bool + func (p *PlaceHolderToken) WaitTimeout(t time.Duration) bool + type ProxyFunction func(req *http.Request) (*url.URL, error) + type PublishToken struct + func (b *PublishToken) Done() <-chan struct{} + func (b *PublishToken) Error() error + func (b *PublishToken) SetCallback(f func(Token)) + func (b *PublishToken) Wait() bool + func (b *PublishToken) WaitTimeout(d time.Duration) bool + func (p *PublishToken) MessageID() uint16 + type ReconnectHandler func(Client, *ClientOptions) + type Store interface + All func() []string + Close func() + Del func(key string) + Get func(key string) packets.ControlPacket + Open func() + Put func(key string, message packets.ControlPacket) + Reset func() + type SubscribeToken struct + func (b *SubscribeToken) Done() <-chan struct{} + func (b *SubscribeToken) Error() error + func (b *SubscribeToken) SetCallback(f func(Token)) + func (b *SubscribeToken) Wait() bool + func (b *SubscribeToken) WaitTimeout(d time.Duration) bool + func (s *SubscribeToken) Result() map[string]byte + type Token interface + Done func() <-chan struct{} + Error func() error + SetCallback func(func(Token)) + Wait func() bool + WaitTimeout func(time.Duration) bool + type TokenErrorSetter interface + type UnsubscribeToken struct + func (b *UnsubscribeToken) Done() <-chan struct{} + func (b *UnsubscribeToken) Error() error + func (b *UnsubscribeToken) SetCallback(f func(Token)) + func (b *UnsubscribeToken) Wait() bool + func (b *UnsubscribeToken) WaitTimeout(d time.Duration) bool + type WebsocketOptions struct + Proxy ProxyFunction + ReadBufferSize int + WriteBufferSize int