Documentation ¶
Index ¶
- func NewBroker(opts ...broker.Option) broker.Broker
- func NewCodec(c io.ReadWriteCloser) codec.Codec
- func Registry(r registry.Registry) broker.Option
- func Secure(b bool) broker.Option
- func SetAutoReconnect(a bool) broker.Option
- func SetBinaryWill(topic string, payload []byte, qos byte, retained bool) broker.Option
- func SetCleanSession(clean bool) broker.Option
- func SetClientID(id string) broker.Option
- func SetCodec(c codec.Marshaler) broker.Option
- func SetConnectTimeout(t time.Duration) broker.Option
- func SetConnectionLostHandler(onLost func(MQTT.Client, error)) broker.Option
- func SetCredentialsProvider(p func() (username string, password string)) broker.Option
- func SetDefaultPublishHandler(defaultHandler func(MQTT.Client, MQTT.Message)) broker.Option
- func SetHTTPHeaders(h http.Header) broker.Option
- func SetKeepAlive(k time.Duration) broker.Option
- func SetMaxReconnectInterval(t time.Duration) broker.Option
- func SetMessageChannelDepth(s uint) broker.Option
- func SetOnConnectHandler(onConn func(MQTT.Client)) broker.Option
- func SetOrderMatters(order bool) broker.Option
- func SetPassword(p string) broker.Option
- func SetPingTimeout(k time.Duration) broker.Option
- func SetProtocolVersion(pv uint) broker.Option
- func SetPubQos(qos byte)
- func SetResumeSubs(resume bool) broker.Option
- func SetRetained(b bool)
- func SetStore(s MQTT.Store) broker.Option
- func SetSubQos(qos byte)
- func SetTLSConfig(t *tls.Config) broker.Option
- func SetUsername(u string) broker.Option
- func SetWill(topic string, payload string, qos byte, retained bool) broker.Option
- func SetWriteTimeout(t time.Duration) broker.Option
- func UnsetWill() broker.Option
- type Codec
- type NoopMarshaler
- type Option
- type Options
- type Subscribers
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SetAutoReconnect ¶
SetAutoReconnect sets whether the automatic reconnection logic should be used when the connection is lost, even if disabled the ConnectionLostHandler is still called
func SetBinaryWill ¶
SetBinaryWill accepts a []byte will message to be set. When the client connects, it will give this will message to the broker, which will then publish the provided payload (the will) to any clients that are subscribed to the provided topic.
func SetCleanSession ¶
SetCleanSession will set the "clean session" flag in the connect message when this client connects to an MQTT broker. By setting this flag, you are indicating that no messages saved by the broker for this client should be delivered. Any messages that were going to be sent by this client before diconnecting previously but didn't will not be sent upon connecting to the broker.
func SetClientID ¶
SetClientID will set the client id to be used by this client when connecting to the MQTT broker. According to the MQTT v3.1 specification, a client id mus be no longer than 23 characters.
func SetConnectTimeout ¶
SetConnectTimeout limits how long the client will wait when trying to open a connection to an MQTT server before timeing out and erroring the attempt. A duration of 0 never times out. Default 30 seconds. Currently only operational on TCP/TLS connections.
func SetConnectionLostHandler ¶
SetConnectionLostHandler will set the OnConnectionLost callback to be executed in the case where the client unexpectedly loses connection with the MQTT broker.
func SetCredentialsProvider ¶
SetCredentialsProvider will set a method to be called by this client when connecting to the MQTT broker that provide the current username and password. Note: without the use of SSL/TLS, this information will be sent in plaintext accross the wire.
func SetDefaultPublishHandler ¶
SetDefaultPublishHandler sets the MessageHandler that will be called when a message is received that does not match any known subscriptions.
func SetHTTPHeaders ¶
SetHTTPHeaders sets the additional HTTP headers that will be sent in the WebSocket opening handshake.
func SetKeepAlive ¶
SetKeepAlive will set the amount of time (in seconds) that the client should wait before sending a PING request to the broker. This will allow the client to know that a connection has not been lost with the server.
func SetMaxReconnectInterval ¶
SetMaxReconnectInterval sets the maximum time that will be waited between reconnection attempts when connection is lost
func SetMessageChannelDepth ¶
SetMessageChannelDepth sets the size of the internal queue that holds messages while the client is temporairily offline, allowing the application to publish when the client is reconnecting. This setting is only valid if AutoReconnect is set to true, it is otherwise ignored.
func SetOnConnectHandler ¶
SetOnConnectHandler sets the function to be called when the client is connected. Both at initial connection time and upon automatic reconnect.
func SetOrderMatters ¶
SetOrderMatters will set the message routing to guarantee order within each QoS level. By default, this value is true. If set to false, this flag indicates that messages can be delivered asynchronously from the client to the application and possibly arrive out of order.
func SetPassword ¶
SetPassword will set the password to be used by this client when connecting to the MQTT broker. Note: without the use of SSL/TLS, this information will be sent in plaintext accross the wire.
func SetPingTimeout ¶
SetPingTimeout will set the amount of time (in seconds) that the client will wait after sending a PING request to the broker, before deciding that the connection has been lost. Default is 10 seconds.
func SetProtocolVersion ¶
SetProtocolVersion sets the MQTT version to be used to connect to the broker. Legitimate values are currently 3 - MQTT 3.1 or 4 - MQTT 3.1.1
func SetResumeSubs ¶
SetResumeSubs will enable resuming of stored (un)subscribe messages when connecting but not reconnecting if CleanSession is false. Otherwise these messages are discarded.
func SetRetained ¶
func SetRetained(b bool)
func SetStore ¶
SetStore will set the implementation of the Store interface used to provide message persistence in cases where QoS levels QoS_ONE or QoS_TWO are used. If no store is provided, then the client will use MemoryStore by default.
func SetTLSConfig ¶
SetTLSConfig will set an SSL/TLS configuration to be used when connecting to an MQTT broker. Please read the official Go documentation for more information.
func SetUsername ¶
SetUsername will set the username to be used by this client when connecting to the MQTT broker. Note: without the use of SSL/TLS, this information will be sent in plaintext accross the wire.
func SetWill ¶
SetWill accepts a string will message to be set. When the client connects, it will give this will message to the broker, which will then publish the provided payload (the will) to any clients that are subscribed to the provided topic.
func SetWriteTimeout ¶
SetWriteTimeout puts a limit on how long a mqtt publish should block until it unblocks with a timeout error. A duration of 0 never times out. Default 30 seconds
Types ¶
type Codec ¶
a json codec, an implementation of github.com/micro/go-micro/codec.Codec it tries to do marshal/unmarshal by github.com/golang/protobuf/jsonpb as possible.
func (*Codec) ReadHeader ¶
type NoopMarshaler ¶
type NoopMarshaler struct{}
a marshaller not care about message header
func NewNoopMarshaler ¶
func NewNoopMarshaler() NoopMarshaler
func (NoopMarshaler) Marshal ¶
func (n NoopMarshaler) Marshal(v interface{}) ([]byte, error)
func (NoopMarshaler) String ¶
func (n NoopMarshaler) String() string
func (NoopMarshaler) Unmarshal ¶
func (n NoopMarshaler) Unmarshal(d []byte, v interface{}) error