client

package
v0.0.0-...-c2aeeca Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2020 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

@Title client.go @Description 客户端 @Author loveward 2020/12/28 12:33

@Title config.go @Description 配置结构体 @Author loveward 2020/12/28 12:36

@Title msg.go @Description 消息结构体 @Author loveward 2020/12/28 12:35

@Title utils.go @Description 工具函数 @Author loveward 2020/12/28 12:37

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Broker    string
	Port      int
	ClientID  string
	Username  string
	Password  string
	SelfTopic string
	CallBack  func(msg *RequestMsg) (*[]byte, error)
	Logger    logger.Logger
}

type Data

type Data struct {
	Key     []byte
	Columns string
}

type RequestMsg

type RequestMsg struct {
	MsgId     string
	Data      Data
	FromTopic string
}

type RespondMsg

type RespondMsg struct {
	RequestMsg     RequestMsg
	Code           float64
	Data           []byte
	ReplyFromTopic string
	Err            error
}

type ZClient

type ZClient struct {
	Logger logger.Logger

	CallBack func(msg *RequestMsg) (*[]byte, error)
	// contains filtered or unexported fields
}

func (*ZClient) Loop

func (z *ZClient) Loop()

func (*ZClient) New

func (z *ZClient) New(c Config) error

使用时只要传入config就行

func (*ZClient) SendMsgAndWaitReply

func (z *ZClient) SendMsgAndWaitReply(data Data, topic string, waitTime int) (RespondMsg, error)

type ZMsg

type ZMsg struct {
	MsgType    int
	MsgContent []byte
}

@Description

此处收到的msg
如果type为0,就是请求
如果type为1,就是应答

Jump to

Keyboard shortcuts

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