mqtt

package
v0.0.0-...-ff68fb7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 26, 2021 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HandleMqttConnection

func HandleMqttConnection(conn net.Conn, ctx *ServerContext)

Types

type ConnectedClient

type ConnectedClient struct {
	Connection    io.Writer
	ClientID      string
	ClientGroup   string
	IsConnected   bool
	IsClean       bool
	Subscriptions map[string]packets.SubOptions
}

ConnectedClient stores the information about a currently connected client

type MqttBase

type MqttBase interface {
	AddClient(io.Writer, *packets.Connect) (reasonCode byte, sessionExists bool, maxQos byte)
	Disconnect(io.Writer, *packets.Disconnect)
	Publish(*packets.Publish)
	Subscribe(io.Writer, *packets.Subscribe) []byte
	Unsubscribe(io.Writer, *packets.Unsubscribe) []byte

	ReservePacketID(io.Writer, *packets.Publish) error
	FreePacketID(io.Writer, *packets.Pubrel) error
}

type MqttHandler

type MqttHandler struct {
	// contains filtered or unexported fields
}

func (*MqttHandler) Handle

func (handler *MqttHandler) Handle(readWriter io.ReadWriter)

type ServerContext

type ServerContext struct {
	// contains filtered or unexported fields
}

ServerContext stores the state of the cluster node

func NewServerContext

func NewServerContext(c *config.Config, logger *zap.Logger) (*ServerContext, error)

NewServerContext creates a new server context.

This should only be called once per cluster node.

func (*ServerContext) AddClient

func (ctx *ServerContext) AddClient(conn io.Writer, connect *packets.Connect) (code byte, sessionExists bool, maxQos byte)

func (*ServerContext) Disconnect

func (ctx *ServerContext) Disconnect(conn io.Writer, disconnect *packets.Disconnect)

func (*ServerContext) FreePacketID

func (ctx *ServerContext) FreePacketID(conn io.Writer, pubRel *packets.Pubrel) error

func (*ServerContext) Publish

func (ctx *ServerContext) Publish(publish *packets.Publish)

Publish publishes a message to a topic

func (*ServerContext) ReservePacketID

func (ctx *ServerContext) ReservePacketID(conn io.Writer, publish *packets.Publish) error

func (*ServerContext) Subscribe

func (ctx *ServerContext) Subscribe(conn io.Writer, subscribe *packets.Subscribe) []byte

func (*ServerContext) Unsubscribe

func (ctx *ServerContext) Unsubscribe(conn io.Writer, unsubscribe *packets.Unsubscribe) []byte

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL