gmqtt

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2023 License: MulanPSL-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	URL      string `json:"url"`
	ClientID string `json:"clientId"`
	Username string `json:"username"`
	Password string `json:"password"`

	MTLS       bool            `json:"mtls"`
	SkipTLSVer bool            `json:"skip_tls_ver"`
	CA         []byte          `json:"-" toml:"-"`
	Cert       tls.Certificate `json:"-" toml:"-"`
}

type GMqtt

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

func New

func New(cfg Config) *GMqtt

func (*GMqtt) Close

func (g *GMqtt) Close()

func (*GMqtt) ConnectToBroker

func (g *GMqtt) ConnectToBroker() (mqtt.Client, error)

func (*GMqtt) GetConnEvent

func (g *GMqtt) GetConnEvent() (bool, error)

GetConnEvent 建立连接后触发后续事件 true:连接成功;false:失去连接

func (*GMqtt) Group

func (g *GMqtt) Group(prefix string, groups ...func(group *RouterGroup)) *RouterGroup

func (*GMqtt) Run

func (g *GMqtt) Run()

func (*GMqtt) Start

func (g *GMqtt) Start() error

Bind Register group routes.

func (*GMqtt) Subscribe

func (g *GMqtt) Subscribe()

type HandlerFunc

type HandlerFunc = func(r *Request)

Request handler function.

type Request

type Request struct {
	Client  mqtt.Client
	Message mqtt.Message
	// contains filtered or unexported fields
}

func (*Request) GetRouterString

func (r *Request) GetRouterString(key string, def ...interface{}) string

GetRouterString retrieves and returns the router value as string with given key name <key>. It returns <def> if <key> does not exist.

func (*Request) GetRouterValue

func (r *Request) GetRouterValue(key string, def ...interface{}) interface{}

GetRouterValue retrieves and returns the router value with given key name <key>. It returns <def> if <key> does not exist.

func (*Request) GetRouterVar

func (r *Request) GetRouterVar(key string, def ...interface{}) *gvar.Var

GetRouterVar retrieves and returns the router value as gvar.Var with given key name <key>. It returns <def> if <key> does not exist.

type Router

type Router struct {
	Uri      string   // URI.
	Method   string   // HTTP method
	Domain   string   // Bound domain.
	RegRule  string   // Parsed regular expression for route matching.
	RegNames []string // Parsed router parameter names.
	Priority int      // Just for reference.
}

Router object.

type RouterGroup

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

RouterGroup is a group wrapping multiple routes and middleware.

func (*RouterGroup) Clone

func (g *RouterGroup) Clone() *RouterGroup

Clone returns a new router group which is a clone of current group.

func (*RouterGroup) GET

func (g *RouterGroup) GET(pattern string, object HandlerFunc) *RouterGroup

GET registers a http handler to given route pattern and http method: GET.

func (*RouterGroup) Group

func (g *RouterGroup) Group(prefix string, groups ...func(group *RouterGroup)) *RouterGroup

Group creates and returns a sub-group of current router group.

Jump to

Keyboard shortcuts

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