mmq

package module
v2.0.0-...-143edb0 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2023 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CmdPublish     = "publish"
	CmdSubscribe   = "subscribe"
	CmdUnsubscribe = "unsubscribe"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	OnClientMsgRecv OnClientMsgRecv
	// contains filtered or unexported fields
}

Client 客户端

func NewClient

func NewClient(addr string) *Client

NewClient 启动客户端

func (*Client) Publish

func (c *Client) Publish(topic string, data []byte) error

Publish 客户端发布消息

func (*Client) SetOnMsgRecv

func (c *Client) SetOnMsgRecv(handler OnClientMsgRecv) *Client

func (*Client) Start

func (c *Client) Start() error

func (*Client) Stop

func (c *Client) Stop()

func (*Client) Subscribe

func (c *Client) Subscribe(topics []string) error

Subscribe 客户端订阅主题

func (*Client) Unsubscribe

func (c *Client) Unsubscribe(topics []string) error

Unsubscribe 客户端取消订阅主题

type Command

type Command struct {
	Cmd   string
	Topic string
	Data  []byte
}

func (*Command) FromBytes

func (s *Command) FromBytes(b []byte) error

func (*Command) ToBytes

func (s *Command) ToBytes() ([]byte, error)

type MatchTopicFunc

type MatchTopicFunc func(pubtopic, subtopic string) bool

MatchTopicFunc topic匹配函数

type OnClientMsgRecv

type OnClientMsgRecv func(c *Client, topic string, data []byte, err error)

type Server

type Server struct {
	MatchTopicFunc MatchTopicFunc
	// contains filtered or unexported fields
}

Server 服务端

func NewServer

func NewServer(addr string) *Server

NewServer 创建并启动服务端

func (*Server) SetMatchTopicFunc

func (s *Server) SetMatchTopicFunc(match MatchTopicFunc) *Server

SetMatchTopicFunc 设置topic匹配函数。可以定制

func (*Server) Start

func (s *Server) Start() error

Start 启动服务端

func (*Server) Stop

func (s *Server) Stop()

Stop 停止服务端

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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