Documentation ¶
Index ¶
- Constants
- func NewLogger(cnf loggingConfig) *zap.Logger
- func Recover(callback func(err, stack string))
- func Retry(packetID uint16, msg *clientMessage)
- type Broker
- func (b *Broker) Listen() error
- func (b *Broker) Publish(topic, payload []byte, flags publishFlags) bool
- func (b *Broker) PublishRetained(msg *message, sub *subscription)
- func (b *Broker) PublishToClient(client *Client, packetID uint16, cm *clientMessage)
- func (b *Broker) Retain(msg *message, topic []byte)
- func (b *Broker) Subscribe(client *Client, filter []byte, qos byte) bool
- func (b *Broker) Unsubscribe(client *Client, filter []byte) bool
- func (b *Broker) UnsubscribeAll(client *Client)
- type Client
- type Config
Constants ¶
const ( ConnectAccepted byte = iota ConnectUnacceptableProto ConnectIDRejected ConnectBadUsernamePassword ConnectNotAuthorized )
Connect Ack return codes
const ( TypeReserved = iota TypeConnect TypeConnAck TypePublish TypePubAck TypePubRec TypePubRel TypePubComp TypeSubscribe TypeSubAck TypeUnsubscribe TypeUnsubAck TypePingReq TypePingResp TypeDisconnect )
Packet types.
const ( ConnectRemLen = 2 // 2 is constant remaining len as per [3.2.1] ConnectVarHeaderLen = 10 PubackRemLen = 2 // 2 is constant remaining len as per [3.4.1] PubrecRemLen = 2 // 2 is constant remaining len as per [3.5.1] PubrelRemLen = 2 // 2 is constant remaining len as per [3.6.1] PubcompRemLen = 2 // 2 is constant remaining len as per [3.7.1] SubackRemLen = 2 // 2 is constant remaining len as per [3.9.2] UnsubackRemLen = 2 // 2 is constant remaining len as per [3.11.1] PingrespRemLen = 0 // 0 is constant remaining len as per [3.13.1] )
Remaining lengths according to the MQTT spec.
const ( StatusUnacknowledged int32 = iota StatusPubackReceived StatusPubrecReceived StatusPubrelReceived StatusPubcompReceived )
Application Message statuses.
const (
SubackFailureCode byte = 128
)
Subscribe Ack return codes.
Variables ¶
This section is empty.
Functions ¶
func NewLogger ¶
NewLogger initializes a new zap.Logger with lumberjack support to write to log files with rotation.
Types ¶
type Broker ¶
type Broker struct { TopicFilterStorage *topicStorage MessageStore *messageStore SessionStore *sessionStore // contains filtered or unexported fields }
Broker is the main broker struct. Should not be used directly. Use the global GOTT var instead.
var GOTT *Broker
GOTT is a singleton used to save memory instead of keeping a reference inside each Client
func NewBroker ¶
NewBroker initializes a new object of type Broker. You can either use the returned pointer or the global GOTT var. Returns a pointer of type Broker which is also assigned to the global GOTT var and an error. It creates/opens an on-disk session store.
func (*Broker) Listen ¶
Listen starts the broker and listens for new connections on the address provided in the config file.
func (*Broker) Publish ¶
Publish sends out a payload to all clients with subscriptions on a provided topic given the passed publish flags.
func (*Broker) PublishRetained ¶
func (b *Broker) PublishRetained(msg *message, sub *subscription)
PublishRetained is used to publish retained messages to a subscribing client.
func (*Broker) PublishToClient ¶
PublishToClient is used to publish a message with a provided packetId to a specific client.
func (*Broker) Subscribe ¶
Subscribe receives a client, a filter and qos level to create or update a subscription.
func (*Broker) Unsubscribe ¶
Unsubscribe receives a client and a filter to remove a subscription.
func (*Broker) UnsubscribeAll ¶
UnsubscribeAll is used to remove all subscriptions of a client. Currently used when the Client disconnects.