mqttserver

package
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2024 License: ISC Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GizmoHook added in v0.0.12

type GizmoHook struct {
	mqtt.HookBase
	// contains filtered or unexported fields
}

GizmoHook handles all the custom logic for Gizmo

func (*GizmoHook) ID added in v0.0.12

func (gh *GizmoHook) ID() string

ID identifies this hook in the listing.

func (*GizmoHook) OnACLCheck added in v0.0.12

func (gh *GizmoHook) OnACLCheck(cl *mqtt.Client, topic string, write bool) bool

OnACLCheck gets called to work out if a client should be allowed to do things or not. The first check that we make is if the client is in either 127.0.0.0/8 (the server itself) or 100.64.0.0/24 (the FMS netblock). If either of these is true than the result is returned immediately as success. Otherwise the actual team number is checked to make sure it corresponds to the one in the topic.

func (*GizmoHook) OnConnect added in v0.1.2

func (gh *GizmoHook) OnConnect(cl *mqtt.Client, pk packets.Packet) error

OnConnect fires when a client connects, and we use this to forcibly clear all state for clients connecting to the server.

func (*GizmoHook) OnConnectAuthenticate added in v0.0.12

func (gh *GizmoHook) OnConnectAuthenticate(cl *mqtt.Client, pk packets.Packet) bool

OnConnectAuthenticate allows anyone to connect, but what they can then do is pretty heavily limited by the OnACLCheck below.

func (*GizmoHook) OnDisconnect added in v0.0.12

func (gh *GizmoHook) OnDisconnect(cl *mqtt.Client, err error, expire bool)

OnDisconnect fires when a client is disconnected for any reason.

func (*GizmoHook) OnSessionEstablished added in v0.0.12

func (gh *GizmoHook) OnSessionEstablished(cl *mqtt.Client, pk packets.Packet)

OnSessionEstablished happens after a client is completely connected and ready to send and receive data.

func (*GizmoHook) OnStarted added in v0.0.12

func (gh *GizmoHook) OnStarted()

OnStarted happens after the listeners are bound and the server is ready to process connections.

func (*GizmoHook) OnSubscribed added in v0.1.2

func (gh *GizmoHook) OnSubscribed(cl *mqtt.Client, pk packets.Packet, reasonCodes []byte)

OnSubscribed logs subscriptions as they come in for a given client. Useful for debugging and normally a noop.

func (*GizmoHook) Provides added in v0.0.12

func (gh *GizmoHook) Provides(b byte) bool

Provides flags which methods the server will invoke this hook for. Adding or removing methods in this file requires updating this value!

type Option

type Option func(*Server) error

Option enables variadic option passing to the server on startup.

func WithLogger

func WithLogger(l hclog.Logger) Option

WithLogger sets the logger for the server.

func WithStartupWG

func WithStartupWG(wg *sync.WaitGroup) Option

WithStartupWG allows a waitgroup to be passed in so the server can notify when its finished with startup tasks to allow a nice message to be printed to the console.

func WithStats added in v0.1.6

func WithStats(m *metrics.Metrics) Option

WithStats provides a registry for statistics to be retained and kept up with.

type Server

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

Server binds the server's methods

func NewServer

func NewServer(opts ...Option) (*Server, error)

NewServer returns a running mqtt broker

func (*Server) Publish added in v0.1.6

func (s *Server) Publish(topic string, payload []byte, retain bool, qos byte) error

Publish is a passthrough to the underlying server's publish function.

func (*Server) Serve

func (s *Server) Serve(bind string) error

Serve binds and serves mqtt on the bound socket. An error will be returned if the srever cannot initialize.

func (*Server) Shutdown

func (s *Server) Shutdown() error

Shutdown gracefully shuts down the server.

func (*Server) Subscribe added in v0.1.6

func (s *Server) Subscribe(filter string, ID int, handler mqtt.InlineSubFn) error

Subscribe is a passthrough to the underlying server's subscribe function.

type StopHook added in v0.1.6

type StopHook func()

StopHook is a function to be called when the MQTT server shuts down.

Jump to

Keyboard shortcuts

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