Documentation ¶
Overview ¶
Package mqtt implements MQTT clients and servers.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ConnectionErrors = [6]error{ nil, errors.New("Connection Refused: unacceptable protocol version"), errors.New("Connection Refused: identifier rejected"), errors.New("Connection Refused: server unavailable"), errors.New("Connection Refused: bad user name or password"), errors.New("Connection Refused: not authorized"), }
ConnectionErrors is an array of errors corresponding to the Connect return codes specified in the specification.
Functions ¶
This section is empty.
Types ¶
type ClientConn ¶
type ClientConn struct { ClientId string // May be set before the call to Connect. Dump bool // When true, dump the messages in and out. Incoming chan *proto.Publish // Incoming messages arrive on this channel. // contains filtered or unexported fields }
A ClientConn holds all the state associated with a connection to an MQTT server. It should be allocated via NewClientConn. Concurrent access to a ClientConn is NOT safe.
func NewClientConn ¶
func NewClientConn(c net.Conn) *ClientConn
NewClientConn allocates a new ClientConn.
func (*ClientConn) Connect ¶
func (c *ClientConn) Connect(user, pass string) error
Connect sends the CONNECT message to the server. If the ClientId is not already set, use a default (a 63-bit decimal random number). The "clean session" bit is always set.
func (*ClientConn) Disconnect ¶
func (c *ClientConn) Disconnect()
Disconnect sends a DISCONNECT message to the server. This function blocks until the disconnect message is actually sent, and the connection is closed.
func (*ClientConn) PingReq ¶
func (c *ClientConn) PingReq()
func (*ClientConn) Publish ¶
func (c *ClientConn) Publish(m *proto.Publish)
Publish publishes the given message to the MQTT server. The QosLevel of the message must be QosAtLeastOnce for now.
type Server ¶
type Server struct { Done chan struct{} StatsInterval time.Duration // Defaults to 10 seconds. Must be set using sync/atomic.StoreInt64(). Dump bool // When true, dump the messages in and out. // contains filtered or unexported fields }
A Server holds all the state associated with an MQTT server.