Documentation
¶
Index ¶
- Variables
- func ListenAndServe(addr string, handler Handler) error
- func ListenAndServeTLS(addr, certFile, keyFile string, handler Handler) error
- func NewLoggingConnFunc(baseName string, logger log.Logger) func(c net.Conn) net.Conn
- func ReadMQTTMessage(reader io.Reader) (mqttcodec.ControlPacket, error)
- type Conn
- type ConnState
- type Handler
- type HandlerFunc
- type Properties
- type ServeMux
- type Server
- func (srv *Server) Close() error
- func (srv *Server) ListenAndServe() (err error)
- func (srv *Server) ListenAndServeTLS(certFile, keyFile string) (err error)
- func (srv *Server) NumActiveConn() int
- func (srv *Server) NumTotalConn() int64
- func (srv *Server) Serve(l net.Listener) (err error)
- func (srv *Server) ServeTLS(l net.Listener, certFile, keyFile string) error
- func (srv *Server) Shutdown(ctx context.Context) error
Constants ¶
This section is empty.
Variables ¶
View Source
var DefaultServeMux = NewServeMux(log.DefaultLogger)
View Source
var (
ErrServerClosed = errors.New("mqtt: Server closed")
)
Functions ¶
func ListenAndServe ¶
func ListenAndServeTLS ¶
func NewLoggingConnFunc ¶
noinspection GoUnusedExportedFunction
func ReadMQTTMessage ¶
func ReadMQTTMessage(reader io.Reader) (mqttcodec.ControlPacket, error)
Types ¶
type Conn ¶
type Conn interface { io.WriteCloser LocalAddr() net.Addr // Returns the local IP RemoteAddr() net.Addr // Returns the remote IP TLS() *tls.ConnectionState // TLS or nil when not using TLS Context() context.Context // Returns the internal context Connection() net.Conn // Returns network connection Properties() Properties // Data set by handler during connection duration }
Conn interface is used by a handler to send mqtt messages.
type HandlerFunc ¶
type HandlerFunc func(Conn, mqttcodec.ControlPacket)
func (HandlerFunc) ServeMQTT ¶
func (f HandlerFunc) ServeMQTT(c Conn, req mqttcodec.ControlPacket)
type Properties ¶
type ServeMux ¶
type ServeMux struct {
// contains filtered or unexported fields
}
func NewServeMux ¶
type Server ¶
type Server struct { Network string // network of the address - empty string defaults to tcp Addr string // address to listen on, ":1883" if empty Handler Handler // handler to invoke, DefaultServeMux if nil ReadTimeout time.Duration // maximum duration before timing out read of the request WriteTimeout time.Duration // maximum duration before timing out write of the response IdleTimeout time.Duration // maximum amount of time to wait for the next request TLSConfig *tls.Config // optional TLS config, used by ListenAndServeTLS ReaderBufferSize int // read buffer size pro tcp connection (default 1024) WriterBufferSize int // write buffer size pro tcp connection (default 1024) ErrorLog log.Logger ConnDebug func(c net.Conn) net.Conn // optional logging wrapper for all server connections // contains filtered or unexported fields }
A Server defines parameters for running a mqtt server.
func (*Server) ListenAndServe ¶
func (*Server) ListenAndServeTLS ¶
Click to show internal directories.
Click to hide internal directories.