mqttserver

package module
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: May 16, 2023 License: AGPL-3.0 Imports: 8 Imported by: 0

README

功能介绍

本程序是一个mqtt服务端的库,使用本程序可以将自己的go应用变成一个mqtt服务器,这点请与其他mqtt的客户端库进行区分。

使用方法

go get -v -u github.com/worldflyingct/mqttserver

产品说明

GO语言版本并非完整的运行程序,仅仅是一个运行库,方便给自己开发的应用添加mqtt服务器功能。
C语言版本的是完整的运行程序,所有的io操作都是异步非阻塞io,使用了epoll技术实现高并发。

联系我们

公司官网:沃航科技
联系方式:jevian_ma@worldflying.cn

开源协议

本项目开源协议为AGPL或商业授权,如果未经我司同意私自使用该代码,请按照AGPL协议规定开放相关源代码,否则将认定为侵权行为。

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckMqttClients added in v1.1.1

func CheckMqttClients(ms *MqttServer)

func CloseServer

func CloseServer(ms *MqttServer)

func GetMqttDataLength

func GetMqttDataLength(data []byte, num uint32) (uint32, uint32)

func HandleMqttClientRequest

func HandleMqttClientRequest(ms *MqttServer, mqttclient *MqttClient)

func HasSliceValue

func HasSliceValue(arr []*string, d string) bool

func ListenFastHttpWebSocket

func ListenFastHttpWebSocket(ms *MqttServer, ctx *fasthttp.RequestCtx, params *WebSocketParam) error

func ListenNetHttpWebSocket

func ListenNetHttpWebSocket(ms *MqttServer, w http.ResponseWriter, r *http.Request, params *WebSocketParam) error

func PublishData

func PublishData(ms *MqttServer, topic string, msg []byte)

func RemoveClientFromMqttClients

func RemoveClientFromMqttClients(ms *MqttServer, mqttclient *MqttClient)

func RemoveSliceByValue

func RemoveSliceByValue(arrs []*string, d string) []*string

func SendToClient added in v1.2.0

func SendToClient(ms *MqttServer, b, bv5 []byte, topic string)

func StartTcpServer

func StartTcpServer(ms *MqttServer, tcpListen *net.TCPListener)

func Subscribe added in v1.1.4

func Subscribe(ms *MqttServer, topics []string)

func SubscribeAll added in v1.1.5

func SubscribeAll(ms *MqttServer, topics []string)

func Unsubscribe added in v1.1.4

func Unsubscribe(ms *MqttServer, topics []string)

Types

type Callback

type Callback func(topic string, data []byte)

type MqttClient

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

func (MqttClient) Close

func (c MqttClient) Close() error

func (MqttClient) Read

func (c MqttClient) Read(b []byte) (int, error)

func (MqttClient) Write

func (c MqttClient) Write(b []byte) (int, error)

type MqttServer

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

func StartServer

func StartServer(tcpport uint16, username string, password string, topics []string, cb Callback) *MqttServer

type WebSocketParam

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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