realtime

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const TypeWS = "ws"

Variables

View Source
var (
	// ErrInvalidMessage indicates that a message payload was not valid.
	ErrInvalidMessage = errors.New("message type not binary")
)
View Source
var HooksGroupName = "mqtt_hooks"
View Source
var ListenersGroupName = "mqtt_listeners"

Functions

func AllowHook

func AllowHook(ms *MqttServer) error

func AppendHooks

func AppendHooks(ms *MqttServer, hooks ...mqtt.Hook) error

func AppendListeners

func AppendListeners(ms *MqttServer, listeners ...listeners.Listener) error

func Module

func Module(opts ...di.Node) di.Node

Types

type Authorizer

type Authorizer interface {
	Authorize() fiber.Handler
}

func NewAuthorizer

func NewAuthorizer(logger *zap.Logger) Authorizer

type MqttServer

type MqttServer struct {
	*mqtt.Server
}

func NewMqttServer

func NewMqttServer() (*MqttServer, error)

func (*MqttServer) Send

func (m *MqttServer) Send(topic string, payload any, retain bool, qos byte) error

func (*MqttServer) Start

func (m *MqttServer) Start(context.Context) error

func (*MqttServer) Stop

func (m *MqttServer) Stop(context.Context) error

type Server

type Server interface {
	Send(topic string, payload any, retain bool, qos byte) error
	Subscribe(filter string, subscriptionId int, handler mqtt.InlineSubFn) error
	Unsubscribe(filter string, subscriptionId int) error
}

type Websocket

type Websocket struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Websocket is a listener for establishing websocket connections.

func NewWebsocket

func NewWebsocket(app fiber.Router, authorizer Authorizer) *Websocket

NewWebsocket initializes and returns a new Websocket listener, listening on an address.

func (*Websocket) Address

func (l *Websocket) Address() string

Address returns the address of the listener.

func (*Websocket) Close

func (l *Websocket) Close(closeClients listeners.CloseFn)

Close closes the listener and any client connections.

func (*Websocket) Handle

func (l *Websocket) Handle(r fiber.Router)

func (*Websocket) ID

func (l *Websocket) ID() string

ID returns the id of the listener.

func (*Websocket) Init

func (l *Websocket) Init(log *slog.Logger) error

Init initializes the listener.

func (*Websocket) Protocol

func (l *Websocket) Protocol() string

Protocol returns the address of the listener.

func (*Websocket) Serve

func (l *Websocket) Serve(establish listeners.EstablishFn)

Serve starts waiting for new Websocket connections, and calls the connection establishment callback for any received.

Jump to

Keyboard shortcuts

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