listener

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2021 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidMessage = errors.New("Message type not binary")
)

Functions

func MockCloser

func MockCloser(id string)

MockCloser is a function signature which can be used in testing.

func MockEstablisher

func MockEstablisher(id string, c net.Conn, auth mqtt.Auth) error

MockEstablisher is a function signature which can be used in testing.

Types

type HTTPStats

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

HTTPStats is a listener for presenting the server $SYS stats on a JSON http endpoint.

func NewHTTPStats

func NewHTTPStats(id, address string) *HTTPStats

NewHTTPStats initialises and returns a new HTTP listener, listening on an address.

func NewHTTPStatsWithTLS

func NewHTTPStatsWithTLS(id, address string, tls *tls.Config) *HTTPStats

NewHTTPStatsWithTLS initialises and returns a new HTTP listener, listening on an address.

func (*HTTPStats) Auth

func (l *HTTPStats) Auth() mqtt.Auth

func (*HTTPStats) Close

func (l *HTTPStats) Close(closeClients mqtt.CloseFunc)

Close closes the listener and any client connections.

func (*HTTPStats) ID

func (l *HTTPStats) ID() string

ID returns the id of the listener.

func (*HTTPStats) Listen

func (l *HTTPStats) Listen(s *system.Info) error

Listen starts listening on the listener's network address.

func (*HTTPStats) Serve

func (l *HTTPStats) Serve(establish mqtt.EstablishFunc) error

Serve starts listening for new connections and serving responses.

type MockListener

type MockListener struct {
	sync.RWMutex

	Listening bool // indiciate the listener is listening.
	Serving   bool // indicate the listener is serving.

	ErrListen bool // throw an error on listen.
	// contains filtered or unexported fields
}

MockListener is a mock listener for establishing client connections.

func NewMockListener

func NewMockListener(id, address string) *MockListener

NewMockListener returns a new instance of MockListener

func (*MockListener) Close

func (l *MockListener) Close(closer mqtt.CloseFunc)

Close closes the mock listener.

func (*MockListener) ID

func (l *MockListener) ID() string

ID returns the id of the mock listener.

func (*MockListener) IsListening

func (l *MockListener) IsListening() bool

IsServing indicates whether the mock listener is listening.

func (*MockListener) IsServing

func (l *MockListener) IsServing() bool

IsServing indicates whether the mock listener is serving.

func (*MockListener) Listen

func (l *MockListener) Listen(s *system.Info) error

SetConfig sets the configuration values of the mock listener.

func (*MockListener) Serve

func (l *MockListener) Serve(establisher mqtt.EstablishFunc) error

Serve serves the mock listener.

type TCP

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

func NewTCP

func NewTCP(id, address string, auth mqtt.Auth) *TCP

NewTCP initialises and returns a new TCP listener, listening on an address.

func NewTCPWithTLS

func NewTCPWithTLS(id, address string, auth mqtt.Auth, tls *tls.Config) *TCP

NewTCP initialises and returns a new TCP listener, listening on an address.

func (*TCP) Auth

func (l *TCP) Auth() mqtt.Auth

Auth returns the authentication controllers for the listener

func (*TCP) Close

func (l *TCP) Close(closeClients mqtt.CloseFunc)

Close closes the listener and any client connections.

func (*TCP) ID

func (l *TCP) ID() string

ID returns the id of the listener.

func (*TCP) Listen

func (l *TCP) Listen(s *system.Info) error

func (*TCP) Serve

func (l *TCP) Serve(establish mqtt.EstablishFunc) error

type Websocket

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

Websocket is a listener for establishing websocket connections.

func NewWebsocket

func NewWebsocket(id, address string, auth mqtt.Auth) *Websocket

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

func NewWebsocketWithTLS

func NewWebsocketWithTLS(id, address string, auth mqtt.Auth, tls *tls.Config) *Websocket

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

func (*Websocket) Auth

func (l *Websocket) Auth() mqtt.Auth

Auth returns the authentication controllers for the listener

func (*Websocket) Close

func (l *Websocket) Close(closeClients mqtt.CloseFunc)

Close closes the listener and any client connections.

func (*Websocket) ID

func (l *Websocket) ID() string

ID returns the id of the listener.

func (*Websocket) Listen

func (l *Websocket) Listen(s *system.Info) error

Listen starts listening on the listener's network address.

func (*Websocket) Serve

func (l *Websocket) Serve(establish mqtt.EstablishFunc) error

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